#[non_exhaustive]pub struct PageOutput {
pub html: String,
pub csp: String,
pub nonce: CspNonce,
}Expand description
Output from render_page: HTML body + CSP header value + the nonce binding them together.
The HTML and the CSP header are a single unit — the HTML embeds a
per-request nonce that only this policy blesses. Serve them together with
Cache-Control: no-store and never cache the HTML across requests: a
cached body with a fresh policy kills every script, and caching both ships
one static, publicly-known nonce to every user, which defeats nonce-based
CSP entirely.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.html: StringThe complete HTML document.
csp: StringThe Content-Security-Policy header value that blesses it.
nonce: CspNonceThe nonce embedded in html and blessed by csp.
Exposed so a caller can add its own nonced <script>/<style>, or
re-stamp a cached shell, without string-parsing the CSP.
Implementations§
Source§impl PageOutput
impl PageOutput
Sourcepub fn headers(&self) -> Vec<(HeaderName, HeaderValue)>
pub fn headers(&self) -> Vec<(HeaderName, HeaderValue)>
Response headers for this page: content type, no-store, and the CSP.
Reads the (public, mutable) csp field, so a caller that must rewrite
a directive can do so in place first and still use this helper.