Struct axum_helmet::Helmet

source ·
pub struct Helmet {
    pub headers: Vec<Box<dyn Header>>,
}
Expand description

Helmet security headers middleware for ntex services

Examples

use helmet_core::Helmet;

let helmet = Helmet::default();

Adding custom headers

use helmet_core::{Helmet, StrictTransportSecurity};

let helmet = Helmet::new()
   .add(StrictTransportSecurity::new().max_age(31536000).include_sub_domains());

Fields§

§headers: Vec<Box<dyn Header>>

Implementations§

source§

impl Helmet

source

pub fn new() -> Helmet

Create new Helmet instance without any headers applied

source

pub fn add(self, header: impl Header + 'static) -> Helmet

Add header to the middleware

Trait Implementations§

source§

impl Default for Helmet

source§

fn default() -> Helmet

Default Helmet instance with all headers applied

Content-Security-Policy: default-src 'self'; base-uri 'self'; font-src 'self' https: data:; form-action 'self'; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; script-src-attr 'none'; style-src 'self' https: 'unsafe-inline'; upgrade-insecure-requests
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Origin-Agent-Cluster: ?1
Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-DNS-Prefetch-Control: off
X-Download-Options: noopen
X-Frame-Options: sameorigin
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 0

Auto Trait Implementations§

§

impl !RefUnwindSafe for Helmet

§

impl !Send for Helmet

§

impl !Sync for Helmet

§

impl Unpin for Helmet

§

impl !UnwindSafe for Helmet

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.