pub struct MethodRouter { /* private fields */ }Expand description
Maps HTTP methods to handlers for a single path.
Implementations§
Source§impl MethodRouter
impl MethodRouter
Sourcepub fn get<H: Handler<T>, T: 'static>(self, handler: H) -> Self
pub fn get<H: Handler<T>, T: 'static>(self, handler: H) -> Self
Additionally route GET requests to handler.
Sourcepub fn post<H: Handler<T>, T: 'static>(self, handler: H) -> Self
pub fn post<H: Handler<T>, T: 'static>(self, handler: H) -> Self
Additionally route POST requests to handler.
Sourcepub fn put<H: Handler<T>, T: 'static>(self, handler: H) -> Self
pub fn put<H: Handler<T>, T: 'static>(self, handler: H) -> Self
Additionally route PUT requests to handler.
Sourcepub fn patch<H: Handler<T>, T: 'static>(self, handler: H) -> Self
pub fn patch<H: Handler<T>, T: 'static>(self, handler: H) -> Self
Additionally route PATCH requests to handler.
Sourcepub fn delete<H: Handler<T>, T: 'static>(self, handler: H) -> Self
pub fn delete<H: Handler<T>, T: 'static>(self, handler: H) -> Self
Additionally route DELETE requests to handler.
Source§impl MethodRouter
impl MethodRouter
Sourcepub fn on<H: Handler<T>, T: 'static>(self, method: Method, handler: H) -> Self
pub fn on<H: Handler<T>, T: 'static>(self, method: Method, handler: H) -> Self
Route method to handler. Methods outside GET, POST, PUT, PATCH,
DELETE, HEAD, OPTIONS and TRACE are rejected when the app is built.
Sourcepub fn layer<L>(self, layer: L) -> Selfwhere
L: Layer<BoxService>,
L::Service: Service<Request, Response = Response, Error = Infallible> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
pub fn layer<L>(self, layer: L) -> Selfwhere
L: Layer<BoxService>,
L::Service: Service<Request, Response = Response, Error = Infallible> + Clone + Send + Sync + 'static,
<L::Service as Service<Request>>::Future: Send + 'static,
Wrap every handler added so far in layer.
The layer runs after routing and only for this path, so it can be
used for per-route middleware such as siderite_cache::RouteCache.
Handlers added after this call are not wrapped.
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Set the description.
Sourcepub fn operation_id(self, id: impl Into<String>) -> Self
pub fn operation_id(self, id: impl Into<String>) -> Self
Set the operation id.
Sourcepub fn deprecated(self) -> Self
pub fn deprecated(self) -> Self
Mark deprecated.
Hide from the OpenAPI document.
Sourcepub fn status(self, status: StatusCode) -> Self
pub fn status(self, status: StatusCode) -> Self
Success status: replaces a 200 OK produced by the handler at
runtime, and documents the success response under this code.
Sourcepub fn response_model<T: Schema + 'static>(self) -> Self
pub fn response_model<T: Schema + 'static>(self) -> Self
Document the success response body as T (application/json),
independent of the handler’s return type.
Trait Implementations§
Source§impl Clone for MethodRouter
impl Clone for MethodRouter
Source§fn clone(&self) -> MethodRouter
fn clone(&self) -> MethodRouter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MethodRouter
impl Debug for MethodRouter
Source§impl Default for MethodRouter
impl Default for MethodRouter
Source§fn default() -> MethodRouter
fn default() -> MethodRouter
Auto Trait Implementations§
impl !RefUnwindSafe for MethodRouter
impl !UnwindSafe for MethodRouter
impl Freeze for MethodRouter
impl Send for MethodRouter
impl Sync for MethodRouter
impl Unpin for MethodRouter
impl UnsafeUnpin for MethodRouter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read more§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read more§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read more