[][src]Trait rocket_contrib::helmet::Policy

pub trait Policy: Default + Send + Sync + 'static {
    const NAME: &'static str;

    fn header(&self) -> Header<'static>;
}

Trait implemented by security and privacy policy headers.

Types that implement this trait can be enable()d and disable()d on instances of SpaceHelmet.

Associated Constants

const NAME: &'static str

The actual name of the HTTP header.

This name must uniquely identify the header as it is used to determine whether two implementations of Policy are for the same header. Use the real HTTP header's name.

Example

use rocket_contrib::helmet::Policy;

#[derive(Default)]
struct MyPolicy;

impl Policy for MyPolicy {
    const NAME: &'static str = "X-My-Policy";
}
Loading content...

Required methods

fn header(&self) -> Header<'static>

Returns the Header to attach to all outgoing responses.

Example

use rocket::http::Header;
use rocket_contrib::helmet::Policy;

#[derive(Default)]
struct MyPolicy;

impl Policy for MyPolicy {
    fn header(&self) -> Header<'static> {
        Header::new(Self::NAME, "value-to-enable")
    }
}
Loading content...

Implementors

impl Policy for ExpectCt[src]

impl Policy for Frame[src]

impl Policy for Hsts[src]

impl Policy for NoSniff[src]

impl Policy for Referrer[src]

impl Policy for XssFilter[src]

Loading content...