howdy/router
Matches an incoming method and path against a set of controllers.
Types
pub type Match {
Found(
handler: fn(context.Context(Nil)) -> response.Response(
content.Content,
),
params: dict.Dict(String, String),
route: String,
)
MethodNotAllowed(allowed: List(http.Method))
NotFound
}
Constructors
-
Found( handler: fn(context.Context(Nil)) -> response.Response( content.Content, ), params: dict.Dict(String, String), route: String, )A route matched. Params are the values captured by
:namesegments and by a trailing*namesegment, which holds the rest of the path.routeis the pattern that matched, such as/user/:id. -
MethodNotAllowed(allowed: List(http.Method))The path matched at least one route but none with this method. An
OPTIONSrequest never produces this: it is answered bycontroller.options_handlerinstead, and neither does aHEADrequest to a path with aGETroute, which theGEThandler answers.allowedlistsHEADwherever it listsGET. -
NotFoundNothing matched the path.
Values
pub fn match(
controllers: List(controller.Builder(Nil)),
method: http.Method,
path: String,
) -> Match
Find the first route, in declaration order, matching method and path.
For repeated dispatch, howdy.handler compiles the table once.