howdy/router

Types

Handles the router types

pub type Route(a) {
  Get(
    route: String,
    func: fn(Context(a)) -> Response(BitBuilder),
  )
  Post(
    route: String,
    func: fn(Context(a)) -> Response(BitBuilder),
  )
  Put(
    route: String,
    func: fn(Context(a)) -> Response(BitBuilder),
  )
  Patch(
    route: String,
    func: fn(Context(a)) -> Response(BitBuilder),
  )
  Custom(
    method: String,
    route: String,
    func: fn(Context(a)) -> Response(BitBuilder),
  )
  Delete(
    route: String,
    func: fn(Context(a)) -> Response(BitBuilder),
  )
  Static(route: String, file_path: String)
  RouterMap(route: String, routes: List(Route(a)))
  RouterMapWithFilters(
    route: String,
    routes: List(Route(a)),
    filters: List(fn(Filter(a)) -> Filter(a)),
  )
  Spa(route: String, file_path: String, default_file: String)
}

Constructors

  • Get(route: String, func: fn(Context(a)) -> Response(BitBuilder))

    Sets a function response for a request with a get method

  • Post(route: String, func: fn(Context(a)) -> Response(BitBuilder))

    Sets a function response for a request with a post method

  • Put(route: String, func: fn(Context(a)) -> Response(BitBuilder))

    Sets a function response for a request with a put method

  • Patch(
      route: String,
      func: fn(Context(a)) -> Response(BitBuilder),
    )

    Sets a functions response for a request with a patch method

  • Custom(
      method: String,
      route: String,
      func: fn(Context(a)) -> Response(BitBuilder),
    )

    Sets a function with a response for a request with a custom method type

  • Delete(
      route: String,
      func: fn(Context(a)) -> Response(BitBuilder),
    )

    Sets a function with a response for a request with a delete method

  • Static(route: String, file_path: String)

    Sets a wildcard path for the router and trys to match files found in the file_path

  • RouterMap(route: String, routes: List(Route(a)))

    Sets a route that contains a list of other routes

  • RouterMapWithFilters(
      route: String,
      routes: List(Route(a)),
      filters: List(fn(Filter(a)) -> Filter(a)),
    )

    Sets a route that contains a list of other routes and applys a filter to each of the contained routes

  • Spa(route: String, file_path: String, default_file: String)

    Sets a wildcard route that will always foward to a specific file

    Example

    Spa("/", "./priv/static", "./priv/static/client/index.html")