[][src]Struct rocket_cors::Origins

pub struct Origins {
    pub allow_null: bool,
    pub exact: Option<HashSet<String>>,
    pub regex: Option<HashSet<String>>,
}

Origins that are allowed to make CORS requests.

An origin is defined according to the defined syntax.

Origins can be specified as an exact match or using regex.

These Origins are specified as logical ORs. That is, if any of the origins match, the entire request is considered to be valid.

Exact matches are matched exactly with the ASCII Serialization of the origin.

Regular expressions are tested for matches against the ASCII Serialization of the origin.

Opaque Origins

The specification defines an Opaque Origin as one that cannot be recreated. You can refer to the source code for the url::Url::origin method to see how an Opaque Origin is determined. Examples of Opaque origins might include schemes like file:// or Browser specific schemes like "moz-extension:// or chrome-extension://.

Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you attempt to create Cors from CorsOptions, you will get an error.

Warning about Regex expressions

By default, regex expressions are unanchored.

This means that if the regex does not start with ^ or \A, or end with $ or \z, then it is permitted to match anywhere in the text. You are encouraged to use the anchors when crafting your Regex expressions.

Fields

allow_null: bool

Whether null origins are accepted

exact: Option<HashSet<String>>

Origins that must be matched exactly as provided.

These must be valid URL strings that will be parsed and validated when creating Cors.

Exact matches are matched exactly with the ASCII Serialization of the origin.

Opaque Origins

The specification defines an Opaque Origin as one that cannot be recreated. You can refer to the source code for the url::Url::origin method to see how an Opaque Origin is determined. Examples of Opaque origins might include schemes like file:// or Browser specific schemes like "moz-extension:// or chrome-extension://.

Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you attempt to create Cors from CorsOptions, you will get an error.

regex: Option<HashSet<String>>

Origins that will be matched via any regex in this list.

These must be valid Regex that will be parsed and validated when creating Cors.

The regex will be matched according to the ASCII serialization of the incoming Origin.

For more information on the syntax of Regex in Rust, see the documentation.

Regular expressions are tested for matches against the ASCII Serialization of the origin.

Warning about Regex expressions

By default, regex expressions are unanchored.

Trait Implementations

impl Clone for Origins[src]

impl Default for Origins[src]

impl Eq for Origins[src]

impl PartialEq<Origins> for Origins[src]

impl Debug for Origins[src]

impl StructuralPartialEq for Origins[src]

impl StructuralEq for Origins[src]

impl Serialize for Origins[src]

impl<'de> Deserialize<'de> for Origins where
    Origins: Default
[src]

Auto Trait Implementations

impl Send for Origins

impl Sync for Origins

impl Unpin for Origins

impl UnwindSafe for Origins

impl RefUnwindSafe for Origins

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]