module Orion::Router::Routes

Direct including types

Defined in:

orion/router/routes.cr

Macro Summary

Macro Detail

macro connect(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a CONNECT route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro connect(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a CONNECT route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#connect"
end

[View source]
macro connect(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a CONNECT route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: connect
end

[View source]
macro connect(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a CONNECT route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro delete(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a DELETE route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro delete(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a DELETE route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#delete"
end

[View source]
macro delete(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a DELETE route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: delete
end

[View source]
macro delete(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a DELETE route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro get(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a GET route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro get(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a GET route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#get"
end

[View source]
macro get(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a GET route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: get
end

[View source]
macro get(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a GET route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro head(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a HEAD route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro head(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a HEAD route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#head"
end

[View source]
macro head(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a HEAD route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: head
end

[View source]
macro head(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a HEAD route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro match(path, callable, *, via = :all, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a match route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context.

module Callable
  def call(cxt : HTTP::Server::Context)
    # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro match(path, *, to, via = :all, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a match route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#match"
end

[View source]
macro match(path, *, action, controller = CONTROLLER, via = :all, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a match route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: match
end

[View source]
macro match(path, *, via = :all, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a match route with a block.

You can route to any object that responds to call with an HTTP::Server::Context.

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro mount(app, *, at = "/") #

Mount an application at the specified path.


[View source]
macro options(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a OPTIONS route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro options(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a OPTIONS route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#options"
end

[View source]
macro options(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a OPTIONS route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: options
end

[View source]
macro options(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a OPTIONS route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro patch(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a PATCH route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro patch(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a PATCH route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#patch"
end

[View source]
macro patch(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a PATCH route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: patch
end

[View source]
macro patch(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a PATCH route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro post(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a POST route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro post(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a POST route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#post"
end

[View source]
macro post(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a POST route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: post
end

[View source]
macro post(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a POST route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro put(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a PUT route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro put(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a PUT route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#put"
end

[View source]
macro put(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a PUT route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: put
end

[View source]
macro put(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a PUT route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro root(callable, *, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Define a GET / route at the current path with a callable object.

module Callable
  def call(cxt : HTTP::Server::Context)
    # ... do something
  end
end

router MyRouter do
  root Callable
end

[View source]
macro root(*, to, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Define a GET / route at the current path with a controller and action (short form).

router MyRouter do
  root to: "#action"
end

[View source]
macro root(*, action, controller = CONTROLLER, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Define a GET / route at the current path with a controller and action (long form).

router MyRouter do
  root controller: Controller action: action
end

[View source]
macro root(*, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Define a GET / route at the current path with a callable object.

router MyRouter do
  root do |context|
    # ...
  end
end

[View source]
macro trace(path, callable, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a TRACE route to a callable object.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

module Callable
  def call(cxt : HTTP::Server::Context)
  # ... do something
  end
end

router MyRouter do
  match "/path", Callable
end

[View source]
macro trace(path, *, to, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a TRACE route to a controller and action (short form). You can route to a controller and action by passing the to argument in the form of "#action".

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", to: "My#trace"
end

[View source]
macro trace(path, *, action, controller = CONTROLLER, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil) #

Defines a TRACE route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyController
  def new(@context : HTTP::Server::Context)
  end

  def match
    # ... do something
  end
end

router MyRouter do
  match "/path", controller: MyController, action: trace
end

[View source]
macro trace(path, *, helper = nil, constraints = nil, format = nil, accept = nil, content_type = nil, type = nil, &block) #

Defines a TRACE route with a block.

You can route to any object that responds to call with an HTTP::Server::Context, this also works for any Proc(HTTP::Server::Context, _).

router MyRouter do
  match "/path" do |context|
    # ... do something
  end
end

[View source]
macro ws(path, ws_callable, *, helper = nil) #

Defines a websocket route to a callable object.

You can route to any object that responds to call with a HTTP::WebSocket and an HTTP::Server::Context.

module Callable
  def call(ws : HTTP::WebSocket, cxt : HTTP::Server::Context)
    # ... do something
  end
end

router MyRouter do
  ws "/path", Callable
end

[View source]
macro ws(path, *, to, helper = nil) #

Defines a websocket route to a websocket compatible controller and action (short form). You can route to a controller and action by passing the to argument in the form of "MyWebSocket#action".

class MyWebSocketController
  def new(@ws : HTTP::WebSocket, @context : HTTP::Server::Context)
  end

  def ws
    # ... do something
  end
end

router MyRouter do
  ws "/path", to: "MyWebSocket#ws"
end

[View source]
macro ws(path, *, action, controller = CONTROLLER, helper = nil) #

Defines a match route to a controller and action (long form). You can route to a controller and action by passing the controller and action arguments, if action is omitted it will default to match.

class MyWebSocketController
  def new(@ws : HTTP::WebSocket, @context : HTTP::Server::Context)
  end

  def ws
    # ... do something
  end
end

router MyRouter do
  ws "/path", controller: MyWebSocketController, action: ws
end

[View source]
macro ws(path, *, helper = nil, &block) #

Defines a match route with a block.

You can route to any object that responds to call with an HTTP::Server::Context.

router MyRouter do
  ws "/path" do |web_socket, context|
    # ... do something
  end
end

[View source]