class Marten::Routing::Map

Defined in:

marten/routing/map.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Class Method Detail

def self.draw(&) #

[View source]

Instance Method Detail

def draw(&) #

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

Inserts a new path into the routes map.

The target associated with the considered path must be either a handler (subclass of Marten::Handlers::Base) or another Marten::Routing::Map instance (in case of nested routes maps). 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]
def rules : Array(Marten::Routing::Rule::Base) #

[View source]