pub struct HtmlRewriteLayer<H> { /* private fields */ }html only.Expand description
Layer that applies HtmlRewrite to the responses of the wrapped service.
See the module docs.
Implementations§
Source§impl<H> HtmlRewriteLayer<H>
impl<H> HtmlRewriteLayer<H>
Sourcepub fn new(selectors: impl IntoIterator<Item = Selector>, handler: H) -> Self
pub fn new(selectors: impl IntoIterator<Item = Selector>, handler: H) -> Self
Creates a new HtmlRewriteLayer that rewrites elements matching
selectors with handler (the handler is cloned per response, so it
starts fresh for each one).
Sourcepub fn with_rewrite_policy(
self,
policy: impl Fn(&HeaderMap, &Extensions) -> bool + Send + Sync + 'static,
) -> Self
pub fn with_rewrite_policy( self, policy: impl Fn(&HeaderMap, &Extensions) -> bool + Send + Sync + 'static, ) -> Self
Sets a custom response rewrite policy.
The predicate receives the response headers and extensions and can
narrow rewriting beyond the built-in Content-Encoding guard.
Sourcepub fn set_rewrite_policy(
&mut self,
policy: impl Fn(&HeaderMap, &Extensions) -> bool + Send + Sync + 'static,
) -> &mut Self
pub fn set_rewrite_policy( &mut self, policy: impl Fn(&HeaderMap, &Extensions) -> bool + Send + Sync + 'static, ) -> &mut Self
Sets a custom response rewrite policy.
The predicate receives the response headers and extensions and can
narrow rewriting beyond the built-in Content-Encoding guard.
Sourcepub fn rewrite_body<B>(&self, body: B) -> HtmlRewriteBody<B, H>where
H: ElementContentHandler + Clone,
pub fn rewrite_body<B>(&self, body: B) -> HtmlRewriteBody<B, H>where
H: ElementContentHandler + Clone,
Wraps a body directly using this layer’s selector set and handler.
This is useful for services that need request-specific gating before deciding whether a single response body should be rewritten, while still sharing the same layer configuration.
Trait Implementations§
Source§impl<H: Clone> Clone for HtmlRewriteLayer<H>
impl<H: Clone> Clone for HtmlRewriteLayer<H>
Source§fn clone(&self) -> HtmlRewriteLayer<H>
fn clone(&self) -> HtmlRewriteLayer<H>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<H: Debug> Debug for HtmlRewriteLayer<H>
impl<H: Debug> Debug for HtmlRewriteLayer<H>
Source§impl<S, H: Clone> Layer<S> for HtmlRewriteLayer<H>
impl<S, H: Clone> Layer<S> for HtmlRewriteLayer<H>
Source§type Service = HtmlRewrite<S, H>
type Service = HtmlRewrite<S, H>
Source§fn layer(&self, inner: S) -> Self::Service
fn layer(&self, inner: S) -> Self::Service
Source§fn into_layer(self, inner: S) -> Self::Service
fn into_layer(self, inner: S) -> Self::Service
layer but consuming self after the service was created. Read moreAuto Trait Implementations§
impl<H> !RefUnwindSafe for HtmlRewriteLayer<H>
impl<H> !UnwindSafe for HtmlRewriteLayer<H>
impl<H> Freeze for HtmlRewriteLayer<H>where
H: Freeze,
impl<H> Send for HtmlRewriteLayer<H>where
H: Send,
impl<H> Sync for HtmlRewriteLayer<H>where
H: Sync,
impl<H> Unpin for HtmlRewriteLayer<H>where
H: Unpin,
impl<H> UnsafeUnpin for HtmlRewriteLayer<H>where
H: UnsafeUnpin,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more