pub struct Helmet { /* private fields */ }Expand description
The set of security headers to apply to every response.
All headers are configured through a builder-style API. Call
Helmet::new() (or Default::default()) to start from the secure
defaults, then chain methods to customise individual headers.
§Examples
use rune_axum_helmet::{Helmet, Hsts, XFrameOptions};
let helmet = Helmet::new()
.frame_options(XFrameOptions::Deny)
.hsts(Hsts::new().max_age(63_072_000))
.csp("default-src 'self'");Implementations§
Source§impl Helmet
impl Helmet
Sourcepub fn frame_options(self, value: XFrameOptions) -> Helmet
pub fn frame_options(self, value: XFrameOptions) -> Helmet
Sets the X-Frame-Options header.
Sourcepub fn no_frame_options(self) -> Helmet
pub fn no_frame_options(self) -> Helmet
Removes the X-Frame-Options header entirely.
Sourcepub fn csp(self, policy: impl Into<String>) -> Helmet
pub fn csp(self, policy: impl Into<String>) -> Helmet
Sets the Content-Security-Policy header to a raw policy string.
Sourcepub fn referrer_policy(self, policy: ReferrerPolicy) -> Helmet
pub fn referrer_policy(self, policy: ReferrerPolicy) -> Helmet
Sets the Referrer-Policy header.
Sourcepub fn cross_origin_opener_policy(
self,
policy: CrossOriginOpenerPolicy,
) -> Helmet
pub fn cross_origin_opener_policy( self, policy: CrossOriginOpenerPolicy, ) -> Helmet
Sets the Cross-Origin-Opener-Policy header.
Sourcepub fn cross_origin_resource_policy(
self,
policy: CrossOriginResourcePolicy,
) -> Helmet
pub fn cross_origin_resource_policy( self, policy: CrossOriginResourcePolicy, ) -> Helmet
Sets the Cross-Origin-Resource-Policy header.
Sourcepub fn cross_origin_embedder_policy(
self,
policy: CrossOriginEmbedderPolicy,
) -> Helmet
pub fn cross_origin_embedder_policy( self, policy: CrossOriginEmbedderPolicy, ) -> Helmet
Sets the Cross-Origin-Embedder-Policy header.
Sourcepub fn permissions_policy(self, policy: impl Into<String>) -> Helmet
pub fn permissions_policy(self, policy: impl Into<String>) -> Helmet
Sets the Permissions-Policy header to a raw policy string.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Helmet
impl RefUnwindSafe for Helmet
impl Send for Helmet
impl Sync for Helmet
impl Unpin for Helmet
impl UnsafeUnpin for Helmet
impl UnwindSafe for Helmet
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