glitr/route
This module exports the Route type and builder functions.
Routes correspond to endpoints on a backend that will be called from a frontend.
They are defined by a method, a path, a query and request/response bodies.
Types
The Route type
Routes should be built using the builder functions
pub type Route(
path_type,
query_type,
req_body_type,
res_body_type,
) {
Route(
method: http.Method,
path: path.RoutePath(path_type),
query: query.RouteQuery(query_type),
req_body: body.RouteBody(req_body_type),
res_body: body.RouteBody(res_body_type),
)
}
Constructors
-
Route( method: http.Method, path: path.RoutePath(path_type), query: query.RouteQuery(query_type), req_body: body.RouteBody(req_body_type), res_body: body.RouteBody(res_body_type), )
Functions
pub fn new() -> Route(Nil, Nil, Nil, Nil)
Create a new Route
By default the method is GET and the path, query and bodies are empty
pub fn with_method(
route: Route(a, b, c, d),
method: Method,
) -> Route(a, b, c, d)
Change the method of a Route
pub fn with_path(
route: Route(a, b, c, d),
path: RoutePath(e),
) -> Route(e, b, c, d)
Change the path of a Route
pub fn with_query(
route: Route(a, b, c, d),
query: RouteQuery(e),
) -> Route(a, e, c, d)
Change the query of a Route
pub fn with_request_body(
route: Route(a, b, c, d),
req_body: RouteBody(e),
) -> Route(a, b, e, d)
Change the request body of a Route
pub fn with_response_body(
route: Route(a, b, c, d),
res_body: RouteBody(e),
) -> Route(a, b, c, e)
Change the response body of a Route