pub struct TowerHttpCompat<L>(/* private fields */);Expand description
A middleware type that bridge xitca-service and tower-service.
Any tower-http type that impl Layer trait can be passed to it and used as xitca-web’s middleware.
§Type mutation
TowerHttpCompat would mutate response body type from B to CompatBody<ResB>. Service enclosed
by it must be able to handle it’s mutation or utilize TypeEraser to erase the mutation.
Implementations§
Source§impl<L> TowerHttpCompat<L>
impl<L> TowerHttpCompat<L>
Sourcepub const fn new(layer: L) -> Self
pub const fn new(layer: L) -> Self
Construct a new xitca-web middleware from tower-http layer type.
§Limitation:
tower::Service::poll_ready implementation is ignored by TowerHttpCompat. if a tower Service is sensitive to poll_ready implementation it should not be used.
§Example:
use xitca_web::middleware::tower_http_compat::TowerHttpCompat;
use tower_http::set_status::SetStatusLayer;
App::new()
.at("/", fn_service(handler))
.enclosed(TowerHttpCompat::new(SetStatusLayer::new(StatusCode::NOT_FOUND)));
Trait Implementations§
Source§impl<L: Clone> Clone for TowerHttpCompat<L>
impl<L: Clone> Clone for TowerHttpCompat<L>
Source§fn clone(&self) -> TowerHttpCompat<L>
fn clone(&self) -> TowerHttpCompat<L>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<L> Freeze for TowerHttpCompat<L>where
L: Freeze,
impl<L> RefUnwindSafe for TowerHttpCompat<L>where
L: RefUnwindSafe,
impl<L> Send for TowerHttpCompat<L>where
L: Send,
impl<L> Sync for TowerHttpCompat<L>where
L: Sync,
impl<L> Unpin for TowerHttpCompat<L>where
L: Unpin,
impl<L> UnsafeUnpin for TowerHttpCompat<L>where
L: UnsafeUnpin,
impl<L> UnwindSafe for TowerHttpCompat<L>where
L: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<S, Arg> ServiceExt<Arg> for Swhere
S: Service<Arg>,
impl<S, Arg> ServiceExt<Arg> for Swhere
S: Service<Arg>,
Source§fn enclosed<T>(self, build: T) -> Pipeline<Self, T, BuildEnclosed>
fn enclosed<T>(self, build: T) -> Pipeline<Self, T, BuildEnclosed>
Enclose Self with given
T as Service<<Self as Service<_>>::Response>>. In other word T
would take Self’s Service::Response type as it’s generic argument of Service<_> impl.Source§fn enclosed_fn<T, Req, O>(
self,
func: T,
) -> Pipeline<Self, AsyncFn<T>, BuildEnclosed>
fn enclosed_fn<T, Req, O>( self, func: T, ) -> Pipeline<Self, AsyncFn<T>, BuildEnclosed>
Function version of Self::enclosed method.
Source§fn map<F, Res, ResMap>(self, mapper: F) -> Pipeline<Self, Map<F>, BuildEnclosed>
fn map<F, Res, ResMap>(self, mapper: F) -> Pipeline<Self, Map<F>, BuildEnclosed>
Mutate
<<Self::Response as Service<Req>>::Future as Future>::Output type with given
closure.