module Athena::Routing::Requirement
#
Includes types related to route requirements.
The namespace also exposes various regex constants representing common universal requirements to make using them in routes easier.
class ExampleController < ATH::Controller
@[ARTA::Get(
"/user/{id}",
requirements: {"id" => ART::Requirement::DIGITS},
)]
def get_user(id : Int64) : Int64
id
end
@[ARTA::Get(
"/article/{slug}",
requirements: {"slug" => ART::Requirement::ASCII_SLUG},
)]
def get_article(slug : String) : String
slug
end
end
Constants#
ASCII_SLUG = /[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*/
#
CATCH_ALL = /.+/
#
DATE_YMD = /[0-9]{4}-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|(?<!02-)3[01])/
#
Matches a date string in the format of YYYY-MM-DD
.