Azu::Router
Defines an Azu Router
The router provides a set of methods for mapping routes that dispatch to specific endpoints or handers. For example
MyAppWeb.router do
root :web, ExampleApp::HelloWorld
ws "/hi", ExampleApp::ExampleChannel
routes :web, "/test" do
get "/hello/", ExampleApp::HelloWorld
get "/hello/:name", ExampleApp::HtmlEndpoint
get "/hello/json", ExampleApp::JsonEndpoint
end
end
You can use most common HTTP verbs: GET, POST, PUT, PATCH, DELETE, TRACE and OPTIONS.
endpoint = ->(env) { [200, {}, ['Hello from Hanami!']] }
get '/hello', to: endpoint
post '/hello', to: endpoint
put '/hello', to: endpoint
patch '/hello', to: endpoint
delete '/hello', to: endpoint
trace '/hello', to: endpoint
options '/hello', to: endpoint
Constants
METHOD_OVERRIDE = "_method"
RESOURCES = ["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"] of ::String
Constructors
new
SourceInstance methods
Registers a route for a given path
add path: '/proc', endpoint: ->(env) { [200, {}, ['Hello from Hanami!']] }, method: Azu::Method::Get
add path: '/endpoint', endpoint: Handler.new, method: Azu::Method::Get
path_cache
Sourceprocess(context : HTTP::Server::Context)
Sourceradix
Sourceroot(endpoint : HTTP::Handler)
Registers the main route of the application
root :web, ExampleApp::HelloWorld
route_info
Get route information for development tools Build array of routes from the routes registry