Struct arc_reactor::routing::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]
impl RouteGroup
pub fn new<T: ToString>(parent: T) -> Self
[src]
pub fn new<T: ToString>(parent: T) -> Self
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]
pub fn group(self, group: RouteGroup) -> Self
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]
pub fn before<T: 'static + MiddleWare<Request>>(self, before: T) -> Self
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]
pub fn after<T: 'static + MiddleWare<Response>>(self, after: T) -> Self
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>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
[src]
pub fn get<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
Add a route and a ServiceHandler for a GET request.
pub fn get2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
[src]
pub fn get2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
pub fn get3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
[src]
pub fn get3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
pub fn get4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
[src]
pub fn get4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
pub fn post<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
[src]
pub fn post<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
Add a route and a Service for a POST request.
pub fn post2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
[src]
pub fn post2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
mount a Service as well as a MiddleWare
pub fn post3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
[src]
pub fn post3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
mount a Service as well as a MiddleWare
pub fn post4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
[src]
pub fn post4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
mount a Service as well as a MiddleWare
pub fn put<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
[src]
pub fn put<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
add a route and a ServiceHandler for a put request
pub fn put2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
[src]
pub fn put2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
pub fn put3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
[src]
pub fn put3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
pub fn put4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
[src]
pub fn put4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
pub fn patch<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
[src]
pub fn patch<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
Add a route and a ServiceHandler for a PATCH request.
pub fn patch2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
[src]
pub fn patch2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
pub fn patch3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
[src]
pub fn patch3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
pub fn patch4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
[src]
pub fn patch4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
pub fn delete<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
[src]
pub fn delete<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static,
Add a route and a ServiceHandler for DELETE request.
pub fn delete2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
[src]
pub fn delete2<S, M>(self, route: &'static str, before: M, handler: S) -> Self where
S: ArcService + 'static,
M: MiddleWare<Request> + 'static,
pub fn delete3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
[src]
pub fn delete3<S, ReqMW, ResMW>(
self,
route: &'static str,
before: ReqMW,
handler: S,
after: ResMW
) -> Self where
S: ArcService + 'static,
ReqMW: MiddleWare<Request> + 'static,
ResMW: MiddleWare<Response> + 'static,
pub fn delete4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
[src]
pub fn delete4<S, M>(self, route: &'static str, handler: S, after: M) -> Self where
S: ArcService + 'static,
M: MiddleWare<Response> + 'static,
Auto Trait Implementations
impl Send for RouteGroup
impl Send for RouteGroup
impl Sync for RouteGroup
impl Sync for RouteGroup