class Telecr::Core::Composer

Overview

Composer runs a chain of middleware and finally executes a handler

Middleware are added via #use and executed in the order they were added. Each middleware receives a context and a "next" function to call. Middleware can:

Defined in:

core/composer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Initialize with empty middleware stack


[View source]

Instance Method Detail

def clear #

Clear all middleware


[View source]
def empty? : Bool #

Check if any middleware is registered


[View source]
def run(ctx : Context, &final : Context -> ) #

Run the middleware chain and final handler

@param ctx [Context] The context to pass through the chain @param final [Proc(Context ->)] The final handler to execute @return [Any] The result from the chain/handler


[View source]
def size : Int32 #

Get number of registered middleware


[View source]
def use(middleware : Middleware) #

Add middleware to the chain

@param middleware [Middleware] The middleware instance to add @return [self] For method chaining


[View source]