Struct worker::Router [−][src]
pub struct Router<'a, D> { /* fields omitted */ }
Expand description
A path-based HTTP router supporting exact-match or wildcard placeholders and shared data.
Implementations
Construct a new Router
, with arbitrary data that will be available to your various routes.
If no data is needed, provide any valid data. The unit type ()
is a good option.
Register an HTTP handler that will exclusively respond to GET requests.
Register an HTTP handler that will exclusively respond to POST requests.
Register an HTTP handler that will respond to any requests.
Register an HTTP handler that will exclusively respond to GET requests. Enables the use of
async/await
syntax in the callback.
pub fn post_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'static,
pub fn post_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'static,
Register an HTTP handler that will exclusively respond to POST requests. Enables the use of
async/await
syntax in the callback.
Register an HTTP handler that will respond to any requests. Enables the use of async/await
syntax in the callback.