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:

orion/dsl/request_methods.cr

Constant Summary

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

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

match "/path", Callable

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

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

[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

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

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

[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

match "/path", Callable

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

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

[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

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

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

[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

match "/path", Callable

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

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

[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

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

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

[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

match "/path", Callable

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

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

[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

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

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

[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

match "/path", Callable

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

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

[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

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

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

[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

match "/path", Callable

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

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

[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

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

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

[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

match "/path", Callable

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

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

[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

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

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

[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

match "/path", Callable

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

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

[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

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

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

[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

match "/path", Callable

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

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

[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

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

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

[View source]