#[non_exhaustive]pub enum CorsOptions {
Disabled,
AllowOrigins(Vec<HeaderValue>),
AllowAnyOrigin,
}Available on crate feature
server only.Expand description
Browser origin policy for HTTP CORS and WebSocket upgrades.
This is not authentication: requests without an Origin header are accepted
by the origin check. Enforce authentication in the host router.
Prefer the constructors; matches outside this crate must include a wildcard arm to accommodate future policies:
use agent_client_protocol_http::CorsOptions;
let policy = CorsOptions::disabled();
let disabled = match policy {
CorsOptions::Disabled => true,
_ => false,
};
assert!(disabled);ⓘ
use agent_client_protocol_http::CorsOptions;
let policy = CorsOptions::disabled();
match policy {
CorsOptions::Disabled => {},
CorsOptions::AllowOrigins(_) => {},
CorsOptions::AllowAnyOrigin => {},
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Disabled
Disable cross-origin HTTP access and reject WebSocket browser origins.
AllowOrigins(Vec<HeaderValue>)
Allow only the listed browser origins.
AllowAnyOrigin
Allow all browser origins. Does not enable credentialed CORS.
Implementations§
Source§impl CorsOptions
impl CorsOptions
Sourcepub fn allow_any_origin() -> Self
pub fn allow_any_origin() -> Self
Allow any browser origin, without enabling credentialed CORS.
Sourcepub fn allow_origins<I, S>(origins: I) -> Result<Self, InvalidHeaderValue>
pub fn allow_origins<I, S>(origins: I) -> Result<Self, InvalidHeaderValue>
Allow the given browser origins.
Trait Implementations§
Source§impl Clone for CorsOptions
impl Clone for CorsOptions
Source§impl Debug for CorsOptions
impl Debug for CorsOptions
Source§impl Default for CorsOptions
impl Default for CorsOptions
impl Eq for CorsOptions
Source§impl PartialEq for CorsOptions
impl PartialEq for CorsOptions
impl StructuralPartialEq for CorsOptions
Auto Trait Implementations§
impl Freeze for CorsOptions
impl RefUnwindSafe for CorsOptions
impl Send for CorsOptions
impl Sync for CorsOptions
impl Unpin for CorsOptions
impl UnsafeUnpin for CorsOptions
impl UnwindSafe for CorsOptions
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
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.