Skip to content

class Athena::Routing::Router
inherits Reference #

Default implementation of ARTA::RouterInterface.

Included modules


Class methods#

.new(request_store : ART::RequestStore, base_uri : URI?) #

View source


#generate(route : String, params : Hash(String, _)? = nil, reference_type : ART::URLGeneratorInterface::ReferenceType = :absolute_path) : String #

Generates a URL to the provided route with the provided params.

By default the path is an ART::URLGeneratorInterface::ReferenceType::Absolute_Path, but can be changed via the reference_type argument.

Any params not related to an argument for the provided route will be added as query params.

require "athena"

class ExampleController < ART::Controller
  @[ARTA::Get("/add/:value1/:value2", name: "add")]
  def add(value1 : Int32, value2 : Int32, negative : Bool = false) : Int32

  def get_link : String

generator.generate "add", value1: 10, value2: 5 # => /add/10/5
View source

#match(request : HTTP::Request) : Amber::Router::RoutedResult(Athena::Routing::ActionBase) #

Matches the provided request with its related ART::Action.

OPTIMIZE: Possibly raise a non ART::Exceptions::HTTPException here to allow caller to determine what to do.

View source

#route_collection : ART::RouteCollection #

Returns the ART::RouteCollection associated with this router.

View source