Crates.io | helmet-core |
lib.rs | helmet-core |
version | 0.1.0 |
source | src |
created_at | 2024-01-05 20:31:03.7362 |
updated_at | 2024-01-05 20:31:03.7362 |
description | HTTP security headers middleware core for various web frameworks |
homepage | https://github.com/danielkov/ntex-helmet |
repository | https://github.com/danielkov/ntex-helmet |
max_upload_size | |
id | 1090419 |
size | 61,452 |
helmet-core
- Security Middleware for popular Rust web frameworksntex-helmet
is a security middleware for the ntex
web framework.actix-web-helmet
is a security middleware for the actix-web
web framework. Coming Soonrocket-helmet
is a security middleware for the rocket
web framework. Coming Soonwarp-helmet
is a security middleware for the warp
web framework. Coming Soonaxum-helmet
is a security middleware for the axum
web framework.It works by setting HTTP headers for you. These headers can help protect your app from some well-known web vulnerabilities:
Add this to your Cargo.toml
:
[dependencies]
helmet-core = "0.1"
Implementing the middleware is different for each framework. See the README for your framework of choice to see how to use it.
use helmet_core::Helmet;
let helmet = Helmet::default();
struct MyCustomFrameworkMiddleware(Helmet);
// Imagine this is a middleware for your favorite framework
impl<S, B> Middleware<S, B> for MyCustomFrameworkMiddleware {
fn start(&self, req: &mut Request<S>) -> Result<Started> {
self.0.headers.iter().for_each(|(k, v)| {
req.headers_mut().insert(k, v.clone());
});
Ok(Started::Done)
}
}
This project is licensed under the MIT license.