pub struct SecureHeadersLayer { /* private fields */ }Expand description
A Tower layer that adds security headers to every response.
Created via SecureHeadersLayer::new(), which sets sensible defaults.
Individual headers can be overridden, disabled, or extended with the
builder methods.
Implementations§
Source§impl SecureHeadersLayer
impl SecureHeadersLayer
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new layer with all default security headers enabled.
Default headers:
X-Content-Type-Options: nosniffX-Frame-Options: DENYX-XSS-Protection: 0Referrer-Policy: strict-origin-when-cross-originContent-Security-Policy: default-src 'self'Permissions-Policy: camera=(), microphone=(), geolocation=()
Sourcepub fn frame_options(self, value: impl Into<String>) -> Self
pub fn frame_options(self, value: impl Into<String>) -> Self
Override the X-Frame-Options header value.
Common values: "DENY", "SAMEORIGIN".
Sourcepub fn content_security_policy(self, value: impl Into<String>) -> Self
pub fn content_security_policy(self, value: impl Into<String>) -> Self
Override the Content-Security-Policy header value.
Sourcepub fn disable_csp(self) -> Self
pub fn disable_csp(self) -> Self
Remove the Content-Security-Policy header entirely.
Trait Implementations§
Source§impl Clone for SecureHeadersLayer
impl Clone for SecureHeadersLayer
Source§fn clone(&self) -> SecureHeadersLayer
fn clone(&self) -> SecureHeadersLayer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SecureHeadersLayer
impl Debug for SecureHeadersLayer
Source§impl Default for SecureHeadersLayer
impl Default for SecureHeadersLayer
Auto Trait Implementations§
impl Freeze for SecureHeadersLayer
impl RefUnwindSafe for SecureHeadersLayer
impl Send for SecureHeadersLayer
impl Sync for SecureHeadersLayer
impl Unpin for SecureHeadersLayer
impl UnsafeUnpin for SecureHeadersLayer
impl UnwindSafe for SecureHeadersLayer
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