bolt_web/middleware/
helmet.rs

1use async_trait::async_trait;
2
3use crate::{request::RequestBody, response::ResponseWriter, types::Middleware};
4
5pub struct Helmet;
6
7#[async_trait]
8impl Middleware for Helmet {
9    async fn run(&self, _req: &mut RequestBody, res: &mut ResponseWriter) {
10        res.set_header("X-DNS-Prefetch-Control", "off");
11        res.set_header("X-Frame-Options", "SAMEORIGIN");
12        res.set_header("X-Content-Type-Options", "nosniff");
13        res.set_header("Referrer-Policy", "no-referrer");
14        res.set_header("Permissions-Policy", "geolocation=(), microphone=()");
15    }
16}