pub struct Route<'a> { /* private fields */ }Expand description
A handle to a route.
All HTTP requests are made against resources. After using Server::at (or
Route::at) to establish a route, the Route type can be used to
establish endpoints for various HTTP methods at that path. Also, using
nest, it can be used to set up a subrouter.
Implementations§
Source§impl<'a> Route<'a>
impl<'a> Route<'a>
Sourcepub fn with(&mut self, middleware: impl Middleware + 'static) -> &mut Self
pub fn with(&mut self, middleware: impl Middleware + 'static) -> &mut Self
Apply the given middleware to the current route.
Sourcepub fn reset_middleware(&mut self) -> &mut Self
pub fn reset_middleware(&mut self) -> &mut Self
Reset the middleware chain for the current route, if any.
Sourcepub fn nest(&mut self, service: Server) -> &mut Self
pub fn nest(&mut self, service: Server) -> &mut Self
Nest a [Server] at the current path.
§Note
The outer server always has precedence when disambiguating
overlapping paths. For example in the following example /hello will
return “Unexpected” to the client
[Server]: struct.Server.html
Sourcepub fn method(
&mut self,
method: Method,
ep: impl Endpoint + 'static,
) -> &mut Self
pub fn method( &mut self, method: Method, ep: impl Endpoint + 'static, ) -> &mut Self
Add an endpoint for the given HTTP method
Sourcepub fn all(&mut self, ep: impl Endpoint + 'static) -> &mut Self
pub fn all(&mut self, ep: impl Endpoint + 'static) -> &mut Self
Add an endpoint for all HTTP methods, as a fallback.
Routes with specific HTTP methods will be tried first.
Sourcepub fn get(&mut self, ep: impl Endpoint + 'static) -> &mut Self
pub fn get(&mut self, ep: impl Endpoint + 'static) -> &mut Self
Add an endpoint for GET requests
Sourcepub fn head(&mut self, ep: impl Endpoint + 'static) -> &mut Self
pub fn head(&mut self, ep: impl Endpoint + 'static) -> &mut Self
Add an endpoint for HEAD requests
Sourcepub fn put(&mut self, ep: impl Endpoint + 'static) -> &mut Self
pub fn put(&mut self, ep: impl Endpoint + 'static) -> &mut Self
Add an endpoint for PUT requests
Sourcepub fn post(&mut self, ep: impl Endpoint + 'static) -> &mut Self
pub fn post(&mut self, ep: impl Endpoint + 'static) -> &mut Self
Add an endpoint for POST requests
Sourcepub fn delete(&mut self, ep: impl Endpoint + 'static) -> &mut Self
pub fn delete(&mut self, ep: impl Endpoint + 'static) -> &mut Self
Add an endpoint for DELETE requests
Sourcepub fn options(&mut self, ep: impl Endpoint + 'static) -> &mut Self
pub fn options(&mut self, ep: impl Endpoint + 'static) -> &mut Self
Add an endpoint for OPTIONS requests
Sourcepub fn connect(&mut self, ep: impl Endpoint + 'static) -> &mut Self
pub fn connect(&mut self, ep: impl Endpoint + 'static) -> &mut Self
Add an endpoint for CONNECT requests