pub struct ContentSecurityPolicy { /* private fields */ }Expand description
Content-Security-Policy header.
Build one with ContentSecurityPolicy::builder. The result implements
Layer (for standalone use) and IntoSecurityHeader
(for use with SecurityHeaders).
§Example
use axum_security::headers::{ContentSecurityPolicy, CspSource};
let csp = ContentSecurityPolicy::builder()
.default_src(CspSource::SELF)
.script_src([CspSource::SELF, CspSource::host("https://cdn.example.com")])
.upgrade_insecure_requests()
.build();Implementations§
Source§impl ContentSecurityPolicy
impl ContentSecurityPolicy
Sourcepub fn builder() -> CspBuilder
pub fn builder() -> CspBuilder
Create a CspBuilder to construct a Content-Security-Policy header.
Trait Implementations§
Source§impl Clone for ContentSecurityPolicy
impl Clone for ContentSecurityPolicy
Source§fn clone(&self) -> ContentSecurityPolicy
fn clone(&self) -> ContentSecurityPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl IntoSecurityHeader for ContentSecurityPolicy
impl IntoSecurityHeader for ContentSecurityPolicy
fn into_header(self) -> (HeaderName, HeaderValue)
Auto Trait Implementations§
impl !Freeze for ContentSecurityPolicy
impl RefUnwindSafe for ContentSecurityPolicy
impl Send for ContentSecurityPolicy
impl Sync for ContentSecurityPolicy
impl Unpin for ContentSecurityPolicy
impl UnsafeUnpin for ContentSecurityPolicy
impl UnwindSafe for ContentSecurityPolicy
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