#[non_exhaustive]pub struct CorsPolicy {
pub allow_credentials: Option<bool>,
pub allow_headers: Vec<String>,
pub allow_methods: Vec<String>,
pub allow_origin_regexes: Vec<String>,
pub allow_origins: Vec<String>,
pub disabled: Option<bool>,
pub expose_headers: Vec<String>,
pub max_age: Option<i32>,
/* private fields */
}region-url-maps or url-maps only.Expand description
The specification for allowing client-side cross-origin requests. For more information about the W3C recommendation for cross-origin resource sharing (CORS), see Fetch API Living Standard.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.allow_credentials: Option<bool>In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header.
Default is false.
allow_headers: Vec<String>Specifies the content for the Access-Control-Allow-Headers header.
allow_methods: Vec<String>Specifies the content for the Access-Control-Allow-Methods header.
allow_origin_regexes: Vec<String>Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax.
An origin is allowed if it matches either an item inallowOrigins or an item inallowOriginRegexes.
Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.
allow_origins: Vec<String>Specifies the list of origins that is allowed to do CORS requests.
An origin is allowed if it matches either an item inallowOrigins or an item inallowOriginRegexes.
disabled: Option<bool>If true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.
expose_headers: Vec<String>Specifies the content for the Access-Control-Expose-Headers header.
max_age: Option<i32>Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.
Implementations§
Source§impl CorsPolicy
impl CorsPolicy
pub fn new() -> Self
Sourcepub fn set_allow_credentials<T>(self, v: T) -> Self
pub fn set_allow_credentials<T>(self, v: T) -> Self
Sets the value of allow_credentials.
§Example
let x = CorsPolicy::new().set_allow_credentials(true);Sourcepub fn set_or_clear_allow_credentials<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_allow_credentials<T>(self, v: Option<T>) -> Self
Sets or clears the value of allow_credentials.
§Example
let x = CorsPolicy::new().set_or_clear_allow_credentials(Some(false));
let x = CorsPolicy::new().set_or_clear_allow_credentials(None::<bool>);Sourcepub fn set_allow_headers<T, V>(self, v: T) -> Self
pub fn set_allow_headers<T, V>(self, v: T) -> Self
Sets the value of allow_headers.
§Example
let x = CorsPolicy::new().set_allow_headers(["a", "b", "c"]);Sourcepub fn set_allow_methods<T, V>(self, v: T) -> Self
pub fn set_allow_methods<T, V>(self, v: T) -> Self
Sets the value of allow_methods.
§Example
let x = CorsPolicy::new().set_allow_methods(["a", "b", "c"]);Sourcepub fn set_allow_origin_regexes<T, V>(self, v: T) -> Self
pub fn set_allow_origin_regexes<T, V>(self, v: T) -> Self
Sets the value of allow_origin_regexes.
§Example
let x = CorsPolicy::new().set_allow_origin_regexes(["a", "b", "c"]);Sourcepub fn set_allow_origins<T, V>(self, v: T) -> Self
pub fn set_allow_origins<T, V>(self, v: T) -> Self
Sets the value of allow_origins.
§Example
let x = CorsPolicy::new().set_allow_origins(["a", "b", "c"]);Sourcepub fn set_disabled<T>(self, v: T) -> Self
pub fn set_disabled<T>(self, v: T) -> Self
Sourcepub fn set_or_clear_disabled<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_disabled<T>(self, v: Option<T>) -> Self
Sourcepub fn set_expose_headers<T, V>(self, v: T) -> Self
pub fn set_expose_headers<T, V>(self, v: T) -> Self
Sets the value of expose_headers.
§Example
let x = CorsPolicy::new().set_expose_headers(["a", "b", "c"]);Sourcepub fn set_max_age<T>(self, v: T) -> Self
pub fn set_max_age<T>(self, v: T) -> Self
Trait Implementations§
Source§impl Clone for CorsPolicy
impl Clone for CorsPolicy
Source§fn clone(&self) -> CorsPolicy
fn clone(&self) -> CorsPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more