Struct tower_surf::Surf
source ยท pub struct Surf { /* private fields */ }Expand description
Implementationsยง
sourceยงimpl Surf
impl Surf
sourcepub fn new(secret: impl Into<String>) -> Self
pub fn new(secret: impl Into<String>) -> Self
Creates a new Surf layer with the provided secret and default token configuration.
Sets the cookie name. Note that this will be previed with __HOST- unless
you have disabled it with prefix. The default value is csrf_token.
sourcepub fn expires(self, expires: Expiration) -> Self
pub fn expires(self, expires: Expiration) -> Self
Sets the cookieโs expiration. The default value is Expiration::Session.
sourcepub fn header_name(self, header_name: impl Into<String>) -> Self
pub fn header_name(self, header_name: impl Into<String>) -> Self
Sets the header name used when validating the request. The default
value is X-CSRF-Token.
sourcepub fn http_only(self, http_only: bool) -> Self
pub fn http_only(self, http_only: bool) -> Self
Sets the HTTPOnly attribute of the cookie. The default value is true.
โ ๏ธ Warning: This should generally not be set to false. See: HttpOnly Cookie Attribute.
sourcepub fn prefix(self, prefix: bool) -> Self
pub fn prefix(self, prefix: bool) -> Self
Sets whether to prefix the cookie name with __HOST-. The default
value is true.
See: Cookie Name.
sourcepub fn same_site(self, same_site: SameSite) -> Self
pub fn same_site(self, same_site: SameSite) -> Self
Sets the SameSite attribute of the cookie. The default value is SameSite::Strict.
sourcepub fn secure(self, secure: bool) -> Self
pub fn secure(self, secure: bool) -> Self
Sets the secure attribute of the cookie. Note that this is required to
be false for cookies to work on localhost. The default value is true.
See: Secure Cookie Attribute.
Trait Implementationsยง
Auto Trait Implementationsยง
impl Freeze for Surf
impl RefUnwindSafe for Surf
impl Send for Surf
impl Sync for Surf
impl Unpin for Surf
impl UnwindSafe for Surf
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
sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
sourceยงunsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)