pub struct Route<'a, 'p, S: State> { /* private fields */ }
Expand description
Returned by App::at and attaches method handlers to a route.
Implementations
sourceimpl<'a, 'p, S: State> Route<'a, 'p, S>
impl<'a, 'p, S: State> Route<'a, 'p, S>
sourcepub fn method(
self,
method: Method,
ep: impl Endpoint<S> + Send + Sync + 'static
) -> Self
pub fn method(
self,
method: Method,
ep: impl Endpoint<S> + Send + Sync + 'static
) -> Self
Attach an endpoint for a specific HTTP method
sourcepub fn all(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
pub fn all(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
Attach an endpoint for all HTTP methods. These will be checked only if no specific endpoint exists for the method.
sourcepub fn get(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
pub fn get(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
Attach an endpoint for GET requests
sourcepub fn post(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
pub fn post(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
Attach an endpoint for POST requests
sourcepub fn put(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
pub fn put(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
Attach an endpoint for PUT requests
sourcepub fn delete(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
pub fn delete(self, ep: impl Endpoint<S> + Send + Sync + 'static) -> Self
Attach an endpoint for DELETE requests
sourcepub fn static_files(self, root: impl Into<PathBuf>) -> Self
pub fn static_files(self, root: impl Into<PathBuf>) -> Self
Serve static files located in the path root
. The path should end with a wildcard segment
(ie. /*
). The wildcard portion of the URL will be appended to root
to form the full
path. The file extension is used to guess a mime type. Files outside of root
will return
a FORBIDDEN error code; ..
and .
path segments are allowed as long as they do not navigate
outside of root
.
sourcepub fn mount<S2>(&mut self, app: App<S2>)where
S2: State,
S2::Context: From<S::Context>,
pub fn mount<S2>(&mut self, app: App<S2>)where
S2: State,
S2::Context: From<S::Context>,
Mount an app to handle all requests from this path.
The path may contain parameters and these will be merged into
the parameters from individual paths in the inner App
.
The App may have a different state type, but its Context
must implement From
to perform
the conversion from the parent state’s Context
- the inner App
’s new_context
won’t
be called.