class Radbas::RouteCollector

Overview

Maps routes and groups them under a common path and middleware.

Included Modules

Direct Known Subclasses

Defined in:

radbas-framework/route_collector.cr

Constructors

Instance Method Summary

Instance methods inherited from module Radbas::MiddlewareCollector

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

Constructor Detail

def self.new(router : Routing::Router(Action), middleware : Array(MiddlewareLike), route_path : String) #

[View source]

Instance Method Detail

def delete(path : String, action : ActionLike, name : String | Nil = nil) : self #

Maps a DELETE route.


[View source]
def get(path : String, action : ActionLike, name : String | Nil = nil) : self #

Maps a GET route.


[View source]
def group(path : String = "", & : RouteCollector -> ) : self #

Yields a collector for routes below path.

The group starts with this collector's middleware. Middleware added to the group applies to all of the group's routes.


[View source]
def head(path : String, action : ActionLike, name : String | Nil = nil) : self #

Maps a HEAD route.


[View source]
def map(method : String, path : String, action : ActionLike, name : String | Nil = nil) : self #

Maps method and path to action, optionally naming the route for Routing::Router#build.


[View source]
def options(path : String, action : ActionLike, name : String | Nil = nil) : self #

Maps a OPTIONS route.


[View source]
def patch(path : String, action : ActionLike, name : String | Nil = nil) : self #

Maps a PATCH route.


[View source]
def post(path : String, action : ActionLike, name : String | Nil = nil) : self #

Maps a POST route.


[View source]
def put(path : String, action : ActionLike, name : String | Nil = nil) : self #

Maps a PUT route.


[View source]
def sse(path : String, handler : StreamHandlerLike, name : String | Nil = nil) : self #

Maps a server-sent events endpoint at path.


[View source]
def ws(path : String, handler : SocketHandlerLike, name : String | Nil = nil) : self #

Maps a websocket endpoint at path.


[View source]