pub struct Cors {
pub allowed_origins: Vec<String>,
pub allowed_methods: Vec<String>,
pub allowed_headers: Vec<String>,
pub expose_headers: Vec<String>,
pub allow_credentials: bool,
pub max_age_secs: Option<u64>,
}Expand description
Route-scoped CORS policy (DW-027, feature analysis 4.14).
Semantics (frozen; evaluation lives in dataplane::cors):
allowed_originsis a closed set of exact origins (https://api.example.com, scheme + host + optional port, compared in normalized form: lowercase scheme/host, default port dropped) or the single entry*(any origin). It must be non-empty;*combined withallow_credentials: trueis rejected by validation (the Fetch spec forbids wildcard-credentialed responses).- A PREFLIGHT (
OPTIONS+Origin+Access-Control-Request-Method) on a CORS-configured route is answered 204 by the gateway — validated against the policy, never forwarded upstream, and never subject to authn/authz/rate limiting (browsers send preflights without credentials). A preflight that fails validation (origin, method, or requested headers not allowed) still short-circuits: 204 with NO CORS headers, which the browser reads as a failed preflight. A plainOPTIONSwithout the preflight markers is NOT intercepted; it proxies normally. - ACTUAL responses on the route carry
Access-Control-Allow-Origin(*, or the echoed request origin when the list is specific),Access-Control-Allow-Credentials: truewhen configured,Access-Control-Expose-Headerswhen configured, andVary: Origin(merged into any existingVary). A request whoseOriginis not allowed simply gets no CORS headers — the response passes through as-is (same-origin reads do not consult CORS at all).
Fields§
§allowed_origins: Vec<String>Origins allowed to call this route cross-origin: exact origin
strings (https://api.example.com, http://localhost:8080) or
* (any origin; never together with allow_credentials).
allowed_methods: Vec<String>Methods allowed for cross-origin requests (preflight echo and actual-request check). Default: the common API set GET/POST/PUT/PATCH/DELETE/HEAD/OPTIONS. Each entry must be a valid HTTP method token; comparison is case-insensitive.
allowed_headers: Vec<String>Request headers clients may send: exact header names, or * to
allow any requested header (never * together with
allow_credentials). Validated against the preflight’s
Access-Control-Request-Headers list; empty means no headers
beyond the CORS-safelisted set are permitted in preflight checks.
expose_headers: Vec<String>Response headers exposed to the browser (readable by cross-origin client script). Absent: only the CORS-safelisted response headers are exposed.
allow_credentials: boolAllow credentialed cross-origin requests (cookies, TLS client
certificates). Default false. When true, the origin list must be
specific (* is rejected by validation) and responses echo the
request origin rather than sending *.
max_age_secs: Option<u64>Access-Control-Max-Age for preflight responses, in seconds (how
long the browser may cache the preflight result). Absent: the
header is omitted (each preflight hits the gateway).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cors
impl<'de> Deserialize<'de> for Cors
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Cors
impl JsonSchema for Cors
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for Cors
Auto Trait Implementations§
impl Freeze for Cors
impl RefUnwindSafe for Cors
impl Send for Cors
impl Sync for Cors
impl Unpin for Cors
impl UnwindSafe for Cors
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more