class
Telecr::Core::Composer
- Telecr::Core::Composer
- Reference
- Object
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:
- Modify the context before passing to next
- Perform actions after next returns
- Stop the chain by not calling next
Defined in:
core/composer.crConstructors
-
.new
Initialize with empty middleware stack
Instance Method Summary
-
#clear
Clear all middleware
-
#empty? : Bool
Check if any middleware is registered
-
#run(ctx : Context, &final : Context -> )
Run the middleware chain and final handler
-
#size : Int32
Get number of registered middleware
-
#use(middleware : Middleware)
Add middleware to the chain
Constructor Detail
Instance Method Detail
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
Add middleware to the chain
@param middleware [Middleware] The middleware instance to add @return [self] For method chaining