salvo-helmet 1.0.1

HTTP security headers middleware for Salvo web framework
Documentation

salvo-helmet - Security Middleware for the Salvo web framework

crate docs

It works by setting HTTP headers for you. These headers can help protect your app from some well-known web vulnerabilities:

Usage

Add this to your Cargo.toml:

[dependencies]
salvo-helmet = "1.0"

Example

use salvo::prelude::*;
use salvo_helmet::{Helmet, HelmetHandler};

#[handler]
async fn index() -> &'static str {
    "Hello, world!"
}

#[tokio::main]
async fn main() {
    let helmet: HelmetHandler = Helmet::default().try_into().unwrap();

    let router = Router::with_hoop(helmet).get(index);

    let acceptor = TcpListener::new("0.0.0.0:3000").bind().await;
    Server::new(acceptor).serve(router).await;
}

License

This project is licensed under the MIT license.