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.
Register an HTTP handler that will exclusively respond to HEAD requests.
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 exclusively respond to PUT requests.
Register an HTTP handler that will exclusively respond to PATCH requests.
Register an HTTP handler that will exclusively respond to DELETE requests.
Register an HTTP handler that will exclusively respond to OPTIONS requests.
Register an HTTP handler that will respond to any requests.
pub fn or_else_any_method(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> Result<Response>
) -> Self
pub fn or_else_any_method(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> Result<Response>
) -> Self
Register an HTTP handler that will respond to all methods that are not handled explicitly by other handlers.
pub fn head_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
pub fn head_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
Register an HTTP handler that will exclusively respond to HEAD requests. Enables the use of
async/await
syntax in the callback.
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>> + 'a,
pub fn post_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
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 exclusively respond to PUT requests. Enables the use of
async/await
syntax in the callback.
pub fn patch_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
pub fn patch_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
Register an HTTP handler that will exclusively respond to PATCH requests. Enables the use of
async/await
syntax in the callback.
pub fn delete_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
pub fn delete_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
Register an HTTP handler that will exclusively respond to DELETE requests. Enables the use
of async/await
syntax in the callback.
pub fn options_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
pub fn options_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
Register an HTTP handler that will exclusively respond to OPTIONS 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.
pub fn or_else_any_method_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
pub fn or_else_any_method_async<T>(
self,
pattern: &str,
func: fn(_: Request, _: RouteContext<D>) -> T
) -> Self where
T: Future<Output = Result<Response>> + 'a,
Register an HTTP handler that will respond to all methods that are not handled explicitly by
other handlers. Enables the use of async/await
syntax in the callback.