module

Orion::DSL::RequestMethods

Request method macros are shorthard ways of constraining a request to a single request method. You can read more about the options available to each of these macros in the Orion::DSL::Match.

Constants

METHODS = ["GET", "HEAD", "POST", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH"] of ::String

Macros

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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#connect"
Source
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

match "/path", controller: MyController, action: connect
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source
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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#delete"
Source
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

match "/path", controller: MyController, action: delete
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source
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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#get"
Source
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

match "/path", controller: MyController, action: get
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source
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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#head"
Source
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

match "/path", controller: MyController, action: head
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source
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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#options"
Source
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

match "/path", controller: MyController, action: options
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source
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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#patch"
Source
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

match "/path", controller: MyController, action: patch
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source
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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#post"
Source
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

match "/path", controller: MyController, action: post
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source
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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#put"
Source
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

match "/path", controller: MyController, action: put
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source
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

match "/path", Callable
Source
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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#trace"
Source
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

match "/path", controller: MyController, action: trace
Source
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 pass a block. Each block will be evaluated as a controller method and have access to all controller helper methods.

match "/path" do
  # ... do something
end
Source