pub enum Credentials {
Omit,
SameOrigin,
Include,
}Expand description
Whether a request made from the browser carries the page’s credentials: its cookies and its HTTP authentication.
These are the three modes of the browser’s own fetch, and the browser host hands the one a request names straight to it. A request that names none sends none, and the browser host then omits credentials. The server host makes its requests from no page, so it has no such credentials to send and ignores the mode.
use simpleplatform_sdk::http::{self, Credentials};
let signed_in: Value = http::fetch(http::Request {
url: "https://api.example.com/session".to_string(),
credentials: Some(Credentials::Include),
..http::Request::default()
})?;
assert_eq!(signed_in["user"], json!("U1"));A cross-origin request that includes them still needs the service to allow the page’s origin and credentials through CORS.
Variants§
Omit
Send no cookies and no HTTP authentication.
SameOrigin
Send them only to the page’s own origin.
Include
Send them to any origin, a cross-origin one included.
Implementations§
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
impl Copy for Credentials
Source§impl Debug for Credentials
impl Debug for Credentials
impl Eq for Credentials
Source§impl PartialEq for Credentials
impl PartialEq for Credentials
impl StructuralPartialEq for Credentials
Auto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnsafeUnpin for Credentials
impl UnwindSafe for Credentials
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