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§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
Source§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer