module Orion::DSL::Root

Overview

The root macro is a shortcut to making a get "/" at the root of you application or at the root of a scope.

Defined in:

orion/dsl/root.cr

Macro Summary

Macro Detail

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]