Skip to main content

CorsConfig

Struct CorsConfig 

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

User-facing configuration for CorsPlugin.

Implementations§

Source§

impl CorsConfig

Inherent builders and presets for CorsConfig.

Source

pub fn permissive() -> Self

Builds a permissive development policy allowing any origin, method, and header.

§Returns
  • Self - Permissive CORS configuration.
Source

pub fn strict<I, S>(origins: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<str>,

Builds a strict allowlist policy accepting only the specified origins.

§Arguments
  • I - Iterator of exact origin strings.
§Returns
  • Self - Strict CORS configuration.
Source

pub fn with_allow_origin(self, allow_origin: AllowOrigin) -> Self

Sets the AllowOrigin policy.

§Arguments
  • AllowOrigin - Desired origin matching policy.
§Returns
  • Self - Updated configuration.
Source

pub fn with_allow_methods<I, S>(self, methods: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Sets the allowed HTTP methods for preflight responses.

§Arguments
  • I - Iterator of HTTP method names.
§Returns
  • Self - Updated configuration.
Source

pub fn with_allow_headers<I, S>(self, headers: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Sets the allowed request headers for preflight responses.

§Arguments
  • I - Iterator of header names.
§Returns
  • Self - Updated configuration.
Source

pub fn with_expose_headers<I, S>(self, headers: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Sets the response headers exposed to cross-origin clients.

§Arguments
  • I - Iterator of exposed header names.
§Returns
  • Self - Updated configuration.
Source

pub fn with_allow_credentials(self, allow_credentials: bool) -> Self

Enables or disables Access-Control-Allow-Credentials: true.

§Arguments
  • bool - Whether credentials may be sent cross-origin.
§Returns
  • Self - Updated configuration.
Source

pub fn with_max_age_secs(self, max_age_secs: Option<u64>) -> Self

Configures the Access-Control-Max-Age cache duration in seconds.

§Arguments
  • Option<u64> - Optional cache lifetime in seconds.
§Returns
  • Self - Updated configuration.
Source

pub fn with_allow_private_network(self, allow_private_network: bool) -> Self

Enables or disables Access-Control-Allow-Private-Network: true responses.

§Arguments
  • bool - Whether private-network preflight requests are approved.
§Returns
  • Self - Updated configuration.
Source§

impl CorsConfig

Source

pub fn get_allow_origin(&self) -> &AllowOrigin

Source

pub fn get_mut_allow_origin(&mut self) -> &mut AllowOrigin

Source

pub fn set_allow_origin(&mut self, val: AllowOrigin) -> &mut Self

Source

pub fn get_allow_methods(&self) -> &Vec<String>

Source

pub fn get_mut_allow_methods(&mut self) -> &mut Vec<String>

Source

pub fn set_allow_methods(&mut self, val: Vec<String>) -> &mut Self

Source

pub fn get_allow_headers(&self) -> &Vec<String>

Source

pub fn get_mut_allow_headers(&mut self) -> &mut Vec<String>

Source

pub fn set_allow_headers(&mut self, val: Vec<String>) -> &mut Self

Source

pub fn get_expose_headers(&self) -> &Vec<String>

Source

pub fn get_mut_expose_headers(&mut self) -> &mut Vec<String>

Source

pub fn set_expose_headers(&mut self, val: Vec<String>) -> &mut Self

Source

pub fn get_allow_credentials(&self) -> bool

Source

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

Source

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

Source

pub fn get_max_age_secs(&self) -> Option<u64>

Source

pub fn try_get_max_age_secs(&self) -> Option<u64>

Source

pub fn get_mut_max_age_secs(&mut self) -> &mut Option<u64>

Source

pub fn set_max_age_secs(&mut self, val: Option<u64>) -> &mut Self

Source

pub fn get_allow_private_network(&self) -> bool

Source

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

Source

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

Trait Implementations§

Source§

impl Clone for CorsConfig

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 CorsConfig

Source§

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

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

impl Default for CorsConfig

Default construction for CorsConfig.

Source§

fn default() -> Self

Constructs a conservative default CorsConfig allowing any origin without credentials.

Auto Trait Implementations§

§

impl !RefUnwindSafe for CorsConfig

§

impl !UnwindSafe for CorsConfig

§

impl Forget for CorsConfig

§

impl Freeze for CorsConfig
where PhantomData<fn() -> XxHash3_64>: Freeze, *const u8 is !null: Freeze, PhantomData<(String, ())>: Freeze, PhantomData<String>: Freeze, *const ArcInner<dyn Fn(&str) -> bool + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&str) -> bool + Sync + Send>>: Freeze,

§

impl Move for CorsConfig

§

impl Send for CorsConfig
where RawTable<(String, ())>: Send, RawVecInner: Send, Arc<dyn Fn(&str) -> bool + Sync + Send>: Send,

§

impl Sync for CorsConfig
where RawTable<(String, ())>: Sync, RawVecInner: Sync, Arc<dyn Fn(&str) -> bool + Sync + Send>: Sync,

§

impl Unpin for CorsConfig
where *const u8 is !null: Unpin, Arc<dyn Fn(&str) -> bool + Sync + Send>: Unpin,

§

impl UnsafeUnpin for CorsConfig

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<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