class Marten::Routing::Map

Defined in:

marten/routing/map.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(namespace : String | Symbol | Nil = nil) #

[View source]

Class Method Detail

def self.draw(namespace : String | Symbol | Nil = nil, &) #

[View source]

Instance Method Detail

def draw(&) #

[View source]
def path(path : String, target : Map, name : String | Symbol | Nil = nil) : Nil #

Inserts a new path into the routes map.

The target associated with the considered path must be a Marten::Routing::Map instance. The <path, target> pair has an optional name that will be prepended to each <path, target> pair inside the Marten::Routing::Map.


[View source]
def path(path : String, target : Marten::Handlers::Base.class, name : String | Symbol) : Nil #

Inserts a new path into the routes map.

The target associated with the considered path must be a handler (subclass of Marten::Handlers::Base). Each <path, target> pair must be given a name that will be used to uniquely identify the route.


[View source]
def resolve(path : String) : Match #

Resolves a path - identify a route matching a specific path.

The route resolution process tries to identify which handler corresponds to the considered path and returns a Marten::Routing::Match object if a match is found. If no match is found a Marten::Routing::Errors::NoResolveMatch exception is raised.


[View source]
def reverse(name : String | Symbol, params : Hash(String | Symbol, Parameter::Types)) #

Reverses a URL - returns the URL corresponding to a specific route name and hash of parameters.

The URL lookup mechanism tries to identify the route matching the given name and tries to apply the parameters defined in the parameters hash passed in the method call. If no route is found or if the arguments can't be applied to the route, a Marten::Routing::Errors::NoReverseMatch exception is raised.


[View source]
def reverse(name : String | Symbol, **kwargs) : String #

Reverses a URL - returns the URL corresponding to a specific route name and parameters.

The URL lookup mechanism tries to identify the route matching the given name and tries to apply any extra parameters passed in the method call. If no route is found or if the arguments can't be applied to the route, a Marten::Routing::Errors::NoReverseMatch exception is raised.


[View source]

[View source]