class Radbas::ApplicationBuilder

Overview

Collects global middleware and routes, then builds the Application.

Global middleware runs for every request, in the order it was added, before the router.

Defined in:

radbas-framework/application_builder.cr

Constructors

Instance Method Summary

Instance methods inherited from class Radbas::RouteCollector

delete(path : String, action : ActionLike, name : String | Nil = nil) : self delete, get(path : String, action : ActionLike, name : String | Nil = nil) : self get, group(path : String = "", & : RouteCollector -> ) : self group, head(path : String, action : ActionLike, name : String | Nil = nil) : self head, map(method : String, path : String, action : ActionLike, name : String | Nil = nil) : self map, options(path : String, action : ActionLike, name : String | Nil = nil) : self options, patch(path : String, action : ActionLike, name : String | Nil = nil) : self patch, post(path : String, action : ActionLike, name : String | Nil = nil) : self post, put(path : String, action : ActionLike, name : String | Nil = nil) : self put, sse(path : String, handler : StreamHandlerLike, name : String | Nil = nil) : self sse, ws(path : String, handler : SocketHandlerLike, name : String | Nil = nil) : self ws

Constructor methods inherited from class Radbas::RouteCollector

new(router : Routing::Router(Action), middleware : Array(MiddlewareLike), route_path : String) new

Instance methods inherited from module Radbas::MiddlewareCollector

add(http_handler : HTTP::Handler) : self
add(middleware : MiddlewareLike) : self
add

Constructor Detail

def self.new(logger : ::Log = Log, router = Routing::Router(Action).new) #

[View source]

Instance Method Detail

def add_error_handler_middleware(error_handler : ErrorHandlerLike = CommonErrorHandler.new(@logger)) : ErrorHandlerMiddleware #

Adds the ErrorHandlerMiddleware, unless already added.

If not added explicitly, #build adds it right after the request logger, so it catches errors of all other middleware.


[View source]
def add_request_logger_middleware(logger : ::Log = @logger) : RequestLoggerMiddleware #

Adds the RequestLoggerMiddleware, unless already added.


[View source]
def add_routing_middleware : RoutingMiddleware #

Adds the RoutingMiddleware, unless already added. Middleware added before it can't see the matched route.

If not added explicitly, #build adds it after all other middleware.


[View source]
def build : Application #

[View source]