pub struct Cors { /* private fields */ }Expand description
A CORS policy.
use web_net::Cors;
let api = Cors::new()
.origin("https://app.example.com")
.headers(&["content-type", "x-csrf-token"])
.credentials()
.max_age(600);Implementations§
Source§impl Cors
impl Cors
Sourcepub fn origin(self, origin: &str) -> Self
pub fn origin(self, origin: &str) -> Self
Allows an origin, exactly as browsers send it
(https://app.example.com, with a port when it has one).
Sourcepub fn any_origin(self) -> Self
pub fn any_origin(self) -> Self
Allows every origin (answered with *). Not with
credentials: the build refuses that pair.
Sourcepub fn headers(self, names: &[&str]) -> Self
pub fn headers(self, names: &[&str]) -> Self
Request fields a cross-origin request may send beyond the simple ones
(content-type, x-csrf-token).
Sourcepub fn expose(self, names: &[&str]) -> Self
pub fn expose(self, names: &[&str]) -> Self
Reply fields a cross-origin script may read beyond the simple ones.
Sourcepub fn credentials(self) -> Self
pub fn credentials(self) -> Self
Cross-origin requests may carry cookies.
Trait Implementations§
impl Eq for Cors
impl StructuralPartialEq for Cors
Auto Trait Implementations§
impl Forget for Cors
impl Freeze for Cors
impl RefUnwindSafe for Cors
impl Send for Cors
impl Sync for Cors
impl Unpin for Cors
impl UnsafeUnpin for Cors
impl UnwindSafe for Cors
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