pub struct Cors {
pub allow_all: bool,
pub allow_origins: Vec<String>,
pub allow_methods: Vec<String>,
pub allow_headers: Vec<String>,
pub allow_credentials: bool,
pub expose_headers: Vec<String>,
pub max_age: String,
}Fields§
§allow_all: bool§allow_origins: Vec<String>§allow_methods: Vec<String>§allow_headers: Vec<String>§allow_credentials: bool§expose_headers: Vec<String>§max_age: StringImplementations§
Source§impl Cors
impl Cors
pub const MAX_AGE: &'static str = "86400"
Sourcepub fn origin_is_allowed(allowed: &str, origin: &str) -> bool
pub fn origin_is_allowed(allowed: &str, origin: &str) -> bool
true when origin is one of the comma-separated allowed origins —
the whole origin, not a substring of the list (#58): with
https://app.example.com allowed, https://app.example.co and
https://app.example.com.evil used to match too. ASCII case is
ignored (scheme and host are case-insensitive).
pub fn get_vary_header_value() -> String
pub fn allow_all(request: &Request) -> Result<Vec<Header>, Error>
pub fn _process(request: &Request, cors: &Cors) -> Result<Vec<Header>, Error>
Sourcepub fn get_headers_from_config(
request: &Request,
config: &ServerConfig,
) -> Vec<Header>
pub fn get_headers_from_config( request: &Request, config: &ServerConfig, ) -> Vec<Header>
Build CORS headers using the provided ServerConfig.
This is the primary implementation. [get_headers] is the legacy
entry point that reads from environment variables; all new call-sites
should prefer this version.
Sourcepub fn process_using_default_config(
request: &Request,
) -> Result<Vec<Header>, Error>
pub fn process_using_default_config( request: &Request, ) -> Result<Vec<Header>, Error>
Legacy entry point that reads CORS settings from environment variables.
Prefer [get_headers_from_config] when a ServerConfig is available
(e.g. inside [App::execute]). This variant is kept for call-sites that
do not yet have an App-level config reference.
Sourcepub fn get_headers(request: &Request) -> Vec<Header>
pub fn get_headers(request: &Request) -> Vec<Header>
Legacy entry point that reads CORS settings from environment variables.
Prefer [get_headers_from_config] when a ServerConfig is available.