glitr/wisp
Types
Functions
pub fn for(
req: Request(Connection),
) -> Result(Router, Response(Body))
Create a new Router for the incoming request
pub fn try(
router_res: Result(Router, Response(Body)),
route: Route(a, b, c, d),
handler: fn(RouteOptions(a, b, c)) -> Result(d, AppError),
) -> Result(Router, Response(Body))
Compare the stored request with the provided Route
If the first parameter has a response, this will be ignored.
Otherwise, if the request match the Route, generate a response based on the provided handler,
else return the Router so that these functions can be chained.
pub fn try_map(
router_res: Result(Router, Response(Body)),
route: Route(a, b, c, d),
handler: fn(RouteOptions(a, b, c)) -> Result(d, AppError),
map_fn: fn(Response(Body)) -> Response(Body),
) -> Result(Router, Response(Body))
Do the same as the try function but also map the generated response
pub fn try_map_service_route(
router_res: Result(Router, Response(Body)),
route: Result(Route(a, b, c, d), GlitrError),
handler: fn(RouteOptions(a, b, c)) -> Result(d, AppError),
map_fn: fn(Response(Body)) -> Response(Body),
) -> Result(Router, Response(Body))
Do the same as try_map, but take a Result(Route, GlitrError) as a parameter
If the route is an Error, a log is printed and the route is ignored
pub fn try_service_route(
router_res: Result(Router, Response(Body)),
route: Result(Route(a, b, c, d), GlitrError),
handler: fn(RouteOptions(a, b, c)) -> Result(d, AppError),
) -> Result(Router, Response(Body))
Do the same as try, but take a Result(Route, GlitrError) as a parameter
If the route is an Error, a log is printed and the route is ignored