class Azu::Router
 
  - Azu::Router
- Reference
- Object
Overview
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
endYou 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: endpointDefined in:
azu/router.crConstant Summary
- 
        METHOD_OVERRIDE = "_method"
- 
        RADIX = Radix::Tree(Route).new
- 
        RESOURCES = ["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"] of ::String
Instance Method Summary
- 
        #add(path : Path, endpoint : HTTP::Handler, method : Method = Method::Any)
        
          Registers a route for a given path 
- #connect(path : Router::Path, handler : HTTP::Handler)
- #delete(path : Router::Path, handler : HTTP::Handler)
- #get(path : Router::Path, handler : HTTP::Handler)
- #head(path : Router::Path, handler : HTTP::Handler)
- #options(path : Router::Path, handler : HTTP::Handler)
- #patch(path : Router::Path, handler : HTTP::Handler)
- #post(path : Router::Path, handler : HTTP::Handler)
- #process(context : HTTP::Server::Context)
- #put(path : Router::Path, handler : HTTP::Handler)
- 
        #root(endpoint : HTTP::Handler)
        
          Registers the main route of the application 
- 
        #routes(scope : String = "", &)
        
          Adds scoped routes 
- #trace(path : Router::Path, handler : HTTP::Handler)
- 
        #ws(path : String, channel : Channel.class)
        
          Registers a websocket route 
Instance Method Detail
Registers a route for a given path
add path: '/proc', endpoint: ->(env) { [200, {}, ['Hello from Hanami!']] }, method: Method::Get
add path: '/endpoint',   endpoint: Handler.new, method: Method::Get
        
        def root(endpoint : HTTP::Handler)
        #
      
      
        Registers the main route of the application
root :web, ExampleApp::HelloWorldRegisters a websocket route
ws "/hi", ExampleApp::ExampleChannel