Skip to main content

RewriteConfig

Struct RewriteConfig 

Source
pub struct RewriteConfig { /* private fields */ }
Expand description

User-facing configuration for RewritePlugin and CompiledRewrite.

Implementations§

Source§

impl RewriteConfig

Fluent configuration builders for RewriteConfig.

Source

pub fn with_force_https(self, force_https: bool) -> Self

Enables or disables redirecting non-HTTPS requests to https://.

§Arguments
  • bool - Whether HTTPS is enforced.
§Returns
  • Self - Updated configuration.
Source

pub fn with_canonical_host<S>(self, host: S) -> Self
where S: Into<String>,

Sets the canonical host (for example "example.com"), redirecting mismatches in a single hop.

§Arguments
  • S - Canonical host value.
§Returns
  • Self - Updated configuration.
Source

pub fn with_canonical_redirect_status(self, status: RedirectStatus) -> Self

Sets the redirect status code used for canonical host and HTTPS redirects.

§Arguments
  • RedirectStatus - Redirect HTTP status (301/302/307/308).
§Returns
  • Self - Updated configuration.
Source

pub fn with_trust_forwarded_proto(self, trust: bool) -> Self

Enables or disables trusting X-Forwarded-Proto and Forwarded when detecting HTTPS.

§Arguments
  • bool - Whether forwarded protocol headers are trusted.
§Returns
  • Self - Updated configuration.
Source

pub fn with_collapse_duplicate_slashes(self, collapse: bool) -> Self

Enables or disables collapsing consecutive duplicate slashes ("//" -> "/").

§Arguments
  • bool - Whether duplicate slashes are collapsed.
§Returns
  • Self - Updated configuration.
Source

pub fn with_trailing_slash( self, mode: TrailingSlashMode, action: RewriteAction, ) -> Self

Configures trailing-slash normalization (Keep, Strip, or Enforce) and its RewriteAction.

§Arguments
  • TrailingSlashMode - Desired trailing-slash policy.
  • RewriteAction - Whether normalization rewrites internally or redirects.
§Returns
  • Self - Updated configuration.
Source

pub fn with_exact_rewrite<F, T>(self, from: F, to: T) -> Self
where F: Into<String>, T: Into<String>,

Adds an O(1) exact-path internal rewrite rule (from -> to).

§Arguments
  • F - Exact incoming path.
  • T - Rewritten internal path.
§Returns
  • Self - Updated configuration.
Source

pub fn with_exact_redirect<F, T>( self, from: F, to: T, status: RedirectStatus, ) -> Self
where F: Into<String>, T: Into<String>,

Adds an O(1) exact-path short-circuit HTTP redirect rule (from -> to).

§Arguments
  • F - Exact incoming path.
  • T - Redirect destination path or URL.
  • RedirectStatus - Redirect HTTP status code.
§Returns
  • Self - Updated configuration.
Source

pub fn with_strip_prefix<F>(self, from: F) -> Self
where F: Into<String>,

Adds a segment-bounded prefix strip rule (for example "/api/v1" strips "/api/v1" internally).

§Arguments
  • F - Incoming path prefix to strip.
§Returns
  • Self - Updated configuration.
Source

pub fn with_prefix_rule<F, T>( self, from: F, to: T, action: RewriteAction, ) -> Self
where F: Into<String>, T: Into<String>,

Adds a segment-bounded prefix rewrite or redirect rule (from -> to).

§Arguments
  • F - Incoming path prefix.
  • T - Replacement prefix.
  • RewriteAction - Internal rewrite or HTTP redirect.
§Returns
  • Self - Updated configuration.
Source

pub fn with_regex_rule<P, R>( self, pattern: P, replacement: R, action: RewriteAction, ) -> Self
where P: Into<String>, R: Into<String>,

Adds a regular-expression rewrite or redirect rule supporting capture replacements ($1, $2).

§Arguments
  • P - Regular expression pattern.
  • R - Replacement template.
  • RewriteAction - Internal rewrite or HTTP redirect.
§Returns
  • Self - Updated configuration.
Source§

impl RewriteConfig

Source

pub fn get_force_https(&self) -> bool

Source

pub fn get_mut_force_https(&mut self) -> &mut bool

Source

pub fn set_force_https(&mut self, val: bool) -> &mut Self

Source

pub fn get_canonical_host(&self) -> Option<String>

Source

pub fn try_get_canonical_host(&self) -> Option<String>

Source

pub fn get_mut_canonical_host(&mut self) -> &mut Option<String>

Source

pub fn set_canonical_host(&mut self, val: Option<String>) -> &mut Self

Source

pub fn get_canonical_redirect_status(&self) -> RedirectStatus

Source

pub fn get_mut_canonical_redirect_status(&mut self) -> &mut RedirectStatus

Source

pub fn set_canonical_redirect_status( &mut self, val: RedirectStatus, ) -> &mut Self

Source

pub fn get_trust_forwarded_proto(&self) -> bool

Source

pub fn get_mut_trust_forwarded_proto(&mut self) -> &mut bool

Source

pub fn set_trust_forwarded_proto(&mut self, val: bool) -> &mut Self

Source

pub fn get_collapse_duplicate_slashes(&self) -> bool

Source

pub fn get_mut_collapse_duplicate_slashes(&mut self) -> &mut bool

Source

pub fn set_collapse_duplicate_slashes(&mut self, val: bool) -> &mut Self

Source

pub fn get_trailing_slash(&self) -> TrailingSlashMode

Source

pub fn get_mut_trailing_slash(&mut self) -> &mut TrailingSlashMode

Source

pub fn set_trailing_slash(&mut self, val: TrailingSlashMode) -> &mut Self

Source

pub fn get_normalization_action(&self) -> RewriteAction

Source

pub fn get_mut_normalization_action(&mut self) -> &mut RewriteAction

Source

pub fn set_normalization_action(&mut self, val: RewriteAction) -> &mut Self

Source

pub fn get_exact_rules(&self) -> &Vec<ExactRewriteRule>

Source

pub fn get_mut_exact_rules(&mut self) -> &mut Vec<ExactRewriteRule>

Source

pub fn set_exact_rules(&mut self, val: Vec<ExactRewriteRule>) -> &mut Self

Source

pub fn get_prefix_rules(&self) -> &Vec<PrefixRewriteRule>

Source

pub fn get_mut_prefix_rules(&mut self) -> &mut Vec<PrefixRewriteRule>

Source

pub fn set_prefix_rules(&mut self, val: Vec<PrefixRewriteRule>) -> &mut Self

Source

pub fn get_regex_rules(&self) -> &Vec<RegexRewriteRule>

Source

pub fn get_mut_regex_rules(&mut self) -> &mut Vec<RegexRewriteRule>

Source

pub fn set_regex_rules(&mut self, val: Vec<RegexRewriteRule>) -> &mut Self

Trait Implementations§

Source§

impl Clone for RewriteConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RewriteConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RewriteConfig

Default construction for RewriteConfig.

Source§

fn default() -> Self

Constructs a no-op default RewriteConfig preserving incoming host, scheme, and path.

§Returns
  • Self - Default configuration.
Source§

impl Eq for RewriteConfig

Source§

impl PartialEq for RewriteConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RewriteConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more