Skip to content

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

RESOURCES = ["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"] of ::String

Methods

#add(path : Path, endpoint : HTTP::Handler, method : Method = Method::Any)

Registers a route for a given path

View source

#connect(path : Router::Path, handler : HTTP::Handler)

View source

#delete(path : Router::Path, handler : HTTP::Handler)

View source

#get(path : Router::Path, handler : HTTP::Handler)

View source

#head(path : Router::Path, handler : HTTP::Handler)

View source

#options(path : Router::Path, handler : HTTP::Handler)

View source

#patch(path : Router::Path, handler : HTTP::Handler)

View source

#post(path : Router::Path, handler : HTTP::Handler)

View source

#process(context : HTTP::Server::Context)

View source

#put(path : Router::Path, handler : HTTP::Handler)

View source

#root(endpoint : HTTP::Handler)

Registers the main route of the application

root :web, ExampleApp::HelloWorld
View source

#routes(scope : String = ""

View source

#trace(path : Router::Path, handler : HTTP::Handler)

View source

#ws(path : String, channel : Channel.class)

Registers a websocket route

ws "/hi", ExampleApp::ExampleChannel
View source