Struct arc_reactor::RouteGroup
[−]
[src]
pub struct RouteGroup { /* fields omitted */ }The routegroup allows for conviniently nesting route handlers and applying group middlewares for protected routes
Methods
impl RouteGroup[src]
pub fn new<T: ToString>(parent: T) -> Self[src]
create a new routegroup with the specified parent
let routegroup = RouteGroup::new("api"); routegroup.get("/users", UserService); // this will match "/api/users"
pub fn group(self, group: RouteGroup) -> Self[src]
Mount a routegroup on this routegroup.
It will apply the middlewares already mounted
on the Parent RouteGroup to all the routes on the child RouteGroup
let routegroup = RouteGroup::new("api"); routegroup.get("/users", UserService); // this will match "/api/users" let nestedgroup = RouteGroup::new("admin"); // by nesting it on `routegroup`, this will match "/api/admin/delete/user" let nestedgroup.get("/delete/user", DeleteService); routegroup.group(nestedgroup);
pub fn before<T: 'static + MiddleWare<Request>>(self, before: T) -> Self[src]
mount a request middleware on this routegroup
ensure that the request middleware is added before any routes on the route group. the middleware only applies to the routes that are added after it has been mounted.
pub fn after<T: 'static + MiddleWare<Response>>(self, after: T) -> Self[src]
mount a response middleware on this routegroup
ensure that the response middleware is added before any routes on the route group. the middleware only applies to the routes that are added after it has been mounted.
pub fn get<S: ArcService + 'static + Send + Sync>(
self,
route: &'static str,
handler: S
) -> Self[src]
self,
route: &'static str,
handler: S
) -> Self
add a route and a ServiceHandler for a get request
pub fn post<S: ArcService + 'static + Send + Sync>(
self,
route: &'static str,
handler: S
) -> Self[src]
self,
route: &'static str,
handler: S
) -> Self
add a route and a ServiceHandler for a post request
pub fn put<S: ArcService + 'static + Send + Sync>(
self,
route: &'static str,
handler: S
) -> Self[src]
self,
route: &'static str,
handler: S
) -> Self
add a route and a ServiceHandler for a put request
pub fn patch<S: ArcService + 'static + Send + Sync>(
self,
route: &'static str,
handler: S
) -> Self[src]
self,
route: &'static str,
handler: S
) -> Self
add a route and a ServiceHandler for a patch request
pub fn delete<S: ArcService + 'static + Send + Sync>(
self,
route: &'static str,
handler: S
) -> Self[src]
self,
route: &'static str,
handler: S
) -> Self
add a route and a ServiceHandler for a delete request