espresso/router

Types

pub type Handler(req, res) {
  ServiceHandler(Map(Method, Service(req, res)))
  RouterHandler(Router(req, res))
}

Constructors

  • ServiceHandler(Map(Method, Service(req, res)))
  • RouterHandler(Router(req, res))
pub type Method {
  ALL
  GET
  POST
  PATCH
  PUT
  DELETE
  HEAD
  OPTIONS
}

Constructors

  • ALL
  • GET
  • POST
  • PATCH
  • PUT
  • DELETE
  • HEAD
  • OPTIONS
pub type Router(req, res) {
  Router(
    middleware: Middleware(req, res, BitString, BitBuilder),
    handlers: Map(String, Handler(req, res)),
  )
}

Constructors

  • Router(
      middleware: Middleware(req, res, BitString, BitBuilder),
      handlers: Map(String, Handler(req, res)),
    )

Functions

pub fn expand(path: String, handlers: Map(String, Handler(a, b)), router: Router(
    a,
    b,
  )) -> Map(String, Handler(a, b))
pub fn get(router: Router(a, b), path: String, handler: fn(
    Request(a),
  ) -> Response(b)) -> Router(a, b)
pub fn handle(router: Router(a, b), routes: Map(
    Method,
    fn(Request(a)) -> Response(b),
  )) -> fn(Request(BitString)) -> Response(BitBuilder)
pub fn new() -> Router(BitString, BitBuilder)
pub fn post(router: Router(a, b), path: String, handler: fn(
    Request(a),
  ) -> Response(b)) -> Router(a, b)
pub fn router(router: Router(a, b), path: String, subrouter: Router(
    a,
    b,
  )) -> Router(a, b)
pub fn to_routes(router: Router(a, b)) -> Map(String, Route)
Search Document