pub trait ServiceExt<R>: Service<R> + Sized {
// Required methods
fn into_make_service(self) -> IntoMakeService<Self>;
fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<Self, C>;
// Provided method
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T> { ... }
}
Expand description
Extension trait that adds additional methods to any Service
.
Required Methods§
Sourcefn into_make_service(self) -> IntoMakeService<Self>
fn into_make_service(self) -> IntoMakeService<Self>
Convert this service into a MakeService
, that is a Service
whose
response is another service.
This is commonly used when applying middleware around an entire Router
. See “Rewriting
request URI in middleware” for more details.
Sourcefn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<Self, C>
Available on crate feature tokio
only.
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<Self, C>
tokio
only.Convert this service into a MakeService
, that will store C
’s
associated ConnectInfo
in a request extension such that ConnectInfo
can extract it.
This enables extracting things like the client’s remote address.
This is commonly used when applying middleware around an entire Router
. See “Rewriting
request URI in middleware” for more details.
Provided Methods§
Sourcefn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
Convert this service into a HandleError
, that will handle errors
by converting them into responses.
See “error handling model” for more details.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.