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 :name segments and by a trailing *name segment, which holds the rest of the path. route is 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 OPTIONS request never produces this: it is answered by controller.options_handler instead, and neither does a HEAD request to a path with a GET route, which the GET handler answers. allowed lists HEAD wherever it lists GET.

  • NotFound

    Nothing 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.

✨ Search Document