Struct arc_reactor::Router
[−]
[src]
pub struct Router { /* fields omitted */ }The main router of you application that is supplied to the ArcReactor.
Methods
impl Router[src]
pub fn new() -> Self[src]
construct a new Router.
pub fn group(self, group: RouteGroup) -> Self[src]
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]
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]
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 + Send + Sync, [src]
S: ArcService + 'static + Send + Sync,
add a route and a ServiceHandler for a get request
pub fn post<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static + Send + Sync, [src]
S: ArcService + 'static + Send + Sync,
add a route and a ServiceHandler for a post request
pub fn put<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static + Send + Sync, [src]
S: ArcService + 'static + Send + Sync,
add a route and a ServiceHandler for a put request
pub fn patch<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static + Send + Sync, [src]
S: ArcService + 'static + Send + Sync,
add a route and a ServiceHandler for a patch request
pub fn delete<S>(self, route: &'static str, handler: S) -> Self where
S: ArcService + 'static + Send + Sync, [src]
S: ArcService + 'static + Send + Sync,
add a route and a ServiceHandler for a delete request
pub fn notFound<S>(self, handler: S) -> Self where
S: ArcService + 'static + Send + Sync, [src]
S: ArcService + 'static + Send + Sync,
add a 404 handler