Router
class Azu::Router
inherits Reference
Azu routing class that allows you to define routes for your application.
ExampleApp.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
Constants
RADIX = Radix::Tree(Route).new
Radix::Tree(Route).new
RESOURCES = ["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"] of ::String
["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"] of ::String
Methods
#add(path : Path, endpoint : HTTP::Handler, method : Method = Method::Any)
(path : Path, endpoint : HTTP::Handler, method : Method = Method::Any)
Registers a route for a given path
#root(endpoint : HTTP::Handler)
(endpoint : HTTP::Handler)
Registers the main route of the application
root :web, ExampleApp::HelloWorld
#ws(path : String, channel : Channel.class)
(path : String, channel : Channel.class)
Registers a websocket route
ws "/hi", ExampleApp::ExampleChannel