module Amber::Router::NamedRoutes

Overview

Provides runtime path and URL helper generation for named routes. Named routes are registered when the route_name: parameter is passed to route definitions in the DSL.

Usage: NamedRoutes.path(:user, id: "5") # => "/users/5" NamedRoutes.url(:user, id: "5") # => "http://localhost:3000/users/5" NamedRoutes.path(:users, page: "2") # => "/users?page=2"

Defined in:

amber/router/named_routes.cr

Class Method Summary

Class Method Detail

def self.path(name : Symbol, **params) : String #

Generates a path string for the given named route, substituting parameter placeholders and appending extra params as query string.


[View source]
def self.url(name : Symbol, **params) : String #

Generates a full URL for the given named route, including scheme, host, and port.


[View source]