pub struct RewriteLayer { /* private fields */ }Expand description
Implementations§
Source§impl RewriteLayer
impl RewriteLayer
pub fn new() -> Self
Sourcepub fn request_header_set(self, name: &str, value: &str) -> Self
pub fn request_header_set(self, name: &str, value: &str) -> Self
Add or replace a request header (case-insensitive name match).
Sourcepub fn request_header_remove(self, name: &str) -> Self
pub fn request_header_remove(self, name: &str) -> Self
Remove a request header (case-insensitive).
Sourcepub fn request_uri_set(self, uri: &str) -> Self
pub fn request_uri_set(self, uri: &str) -> Self
Replace the entire request URI.
Sourcepub fn request_uri_strip_prefix(self, prefix: &str) -> Self
pub fn request_uri_strip_prefix(self, prefix: &str) -> Self
Strip a path prefix from the request URI. No-op if the prefix is absent.
Normalizes to "/" if stripping leaves an empty path.
Sourcepub fn request_uri_add_prefix(self, prefix: &str) -> Self
pub fn request_uri_add_prefix(self, prefix: &str) -> Self
Prepend a prefix to the request URI.
Sourcepub fn response_header_set(self, name: &str, value: &str) -> Self
pub fn response_header_set(self, name: &str, value: &str) -> Self
Add or replace a response header (case-insensitive name match).
Sourcepub fn response_header_remove(self, name: &str) -> Self
pub fn response_header_remove(self, name: &str) -> Self
Remove a response header (case-insensitive).
Sourcepub fn response_status(self, code: i16, reason: &str) -> Self
pub fn response_status(self, code: i16, reason: &str) -> Self
Override the response status code and reason phrase.
Sourcepub fn response_body_replace(self, from: &str, to: &str) -> Self
pub fn response_body_replace(self, from: &str, to: &str) -> Self
Byte-level find-and-replace across all response body content ranges.
Trait Implementations§
Source§impl Middleware for RewriteLayer
impl Middleware for RewriteLayer
fn handle( &self, request: &Request, connection: &ConnectionInfo, next: &dyn Application, ) -> Result<Response, String>
Source§fn runs_inline(&self, _request: &Request, _connection: &ConnectionInfo) -> bool
fn runs_inline(&self, _request: &Request, _connection: &ConnectionInfo) -> bool
true when this layer’s own work for request never blocks (in-memory
state, atomics, short mutexes) — see Application::runs_inline. A
WithMiddleware stack runs inline only if every layer and the inner
application agree. Default false.Source§fn is_passthrough(
&self,
_request: &Request,
_connection: &ConnectionInfo,
) -> bool
fn is_passthrough( &self, _request: &Request, _connection: &ConnectionInfo, ) -> bool
true when handle would do nothing for request but call next
(e.g. a rate limit that isn’t configured). A WithMiddleware stack
offers the inner application’s execute_async only if every layer
passes the request through. Default false.Source§fn accepts_streamed_body(
&self,
_request: &Request,
_connection: &ConnectionInfo,
) -> bool
fn accepts_streamed_body( &self, _request: &Request, _connection: &ConnectionInfo, ) -> bool
true when this layer never reads request.body, so the inner
application may receive it as a stream (Application::streams_body).
A layer that inspects the body (CSRF tokens in a form, request
signatures, rewriting) must keep the default false: it would see an
empty body.Source§fn answers_streamed_body(
&self,
_request: &Request,
_connection: &ConnectionInfo,
) -> bool
fn answers_streamed_body( &self, _request: &Request, _connection: &ConnectionInfo, ) -> bool
true when this layer answers request itself — it doesn’t call
next — and reads its body as a stream (a proxy forwarding it as it
arrives). The body is then streamed whatever the layers after it and
the application would say. Requires accepts_streamed_body. Since
18.3.0.Auto Trait Implementations§
impl Freeze for RewriteLayer
impl RefUnwindSafe for RewriteLayer
impl Send for RewriteLayer
impl Sync for RewriteLayer
impl Unpin for RewriteLayer
impl UnsafeUnpin for RewriteLayer
impl UnwindSafe for RewriteLayer
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