Struct arc_reactor::routing::Router [−][src]
pub struct Router { /* fields omitted */ }
The main router of you application that is supplied to the ArcReactor.
Methods
impl Router
[src]
impl Router
pub fn new() -> Self
[src]
pub fn new() -> Self
Construct a new Router.
pub fn group(self, group: RouteGroup) -> Self
[src]
pub fn group(self, group: RouteGroup) -> Self
Mount a routegroup on this router.
It will apply the middlewares already mounted
on the Router
to all the routes on the RouteGroup
let router = Router::new(); router.get("/users", UserService); // this will match "/users" let nestedgroup = RouteGroup::new("admin"); // by nesting it on `router`, this will match "/admin/delete/user" let nestedgroup.get("/delete/user", DeleteService); router.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 router.
Ensure that the request middleware is added before any routes on the router. 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 reesponse middleware on this router
Ensure that the request middleware is added before any routes on the router. 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,
pub fn notFound<S>(self, handler: S) -> Self where
S: ArcService + 'static,
[src]
pub fn notFound<S>(self, handler: S) -> Self where
S: ArcService + 'static,
Add a 404 handler.
Trait Implementations
impl Clone for Router
[src]
impl Clone for Router
fn clone(&self) -> Router
[src]
fn clone(&self) -> Router
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl ArcService for Router
[src]
impl ArcService for Router
fn call(&self, req: Request, res: Response) -> FutureResponse
[src]
fn call(&self, req: Request, res: Response) -> FutureResponse