Module sensitive_headers
Expand description
Middlewares that mark headers as sensitive.
§Example
use rama_http::layer::sensitive_headers::SetSensitiveHeadersLayer;
use rama_http::{Body, Request, Response, header::AUTHORIZATION};
use rama_core::service::service_fn;
use rama_core::{Context, Service, Layer};
use rama_core::error::BoxError;
use std::{iter::once, convert::Infallible};
async fn handle(req: Request) -> Result<Response, Infallible> {
// ...
}
let mut service = (
// 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.
SetSensitiveHeadersLayer::new(once(AUTHORIZATION)),
).layer(service_fn(handle));
// Call the service.
let response = service
.serve(Context::default(), 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.