Module tower_async_http::sensitive_headers
source · Available on crate feature
sensitive-headers
only.Expand description
Middlewares that mark headers as sensitive.
Example
use tower_async_http::sensitive_headers::SetSensitiveHeadersLayer;
use tower_async::{Service, ServiceExt, ServiceBuilder, service_fn};
use http::{Request, Response, header::AUTHORIZATION};
use hyper::Body;
use std::{iter::once, convert::Infallible};
async fn handle(req: Request<Body>) -> Result<Response<Body>, Infallible> {
// ...
}
let mut service = ServiceBuilder::new()
// Mark the `Authorization` header as sensitive so it doesn't show in logs
//
// `SetSensitiveHeadersLayer` will mark the header as sensitive on both the
// request and response.
//
// The middleware is constructed from an iterator of headers to easily mark
// multiple headers at once.
.layer(SetSensitiveHeadersLayer::new(once(AUTHORIZATION)))
.service(service_fn(handle));
// Call the service.
let response = service
.call(Request::new(Body::empty()))
.await?;
Structs
- Mark headers as sensitive on both requests and responses.
- Mark request headers as sensitive.
- Mark request headers as sensitive.
- Mark response headers as sensitive.
- Mark response headers as sensitive.
Type Aliases
- Mark headers as sensitive on both requests and responses.