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 http_body_util::Full;
use bytes::Bytes;
use std::{iter::once, convert::Infallible};
async fn handle(req: Request<Full<Bytes>>) -> Result<Response<Full<Bytes>>, 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(Full::default()))
.await?;
Structs§
- SetSensitive
Headers Layer - Mark headers as sensitive on both requests and responses.
- SetSensitive
Request Headers - Mark request headers as sensitive.
- SetSensitive
Request Headers Layer - Mark request headers as sensitive.
- SetSensitive
Response Headers - Mark response headers as sensitive.
- SetSensitive
Response Headers Layer - Mark response headers as sensitive.
Type Aliases§
- SetSensitive
Headers - Mark headers as sensitive on both requests and responses.