module Orion::DSL::RequestMethods

Overview

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.

Defined in:

Constant Summary

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

Macro Summary

Macro Detail

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 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

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

match "/path", controller: MyController, action: connect

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#connect"

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

match "/path", Callable

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

match "/path", controller: MyController, action: delete

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 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

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#delete"

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

match "/path", Callable

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

match "/path", Callable

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

match "/path", controller: MyController, action: get

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 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

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#get"

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 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

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

match "/path", controller: MyController, action: head

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#head"

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

match "/path", Callable

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 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

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

match "/path", controller: MyController, action: options

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#options"

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

match "/path", Callable

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

match "/path", controller: MyController, action: patch

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#patch"

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

match "/path", Callable

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 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

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

match "/path", Callable

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 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

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

match "/path", controller: MyController, action: post

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#post"

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 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

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

match "/path", controller: MyController, action: put

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#put"

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

match "/path", Callable

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

match "/path", Callable

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 < BaseController
  def match
    # ... do something
  end
end

match "/path", to: "My#trace"

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

match "/path", controller: MyController, action: trace

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 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