aws_smithy_http_server/instrumentation/sensitivity/mod.rs
1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6//! The combination of [HTTP binding traits] and the [sensitive trait] require us to redact
7//! portions of the HTTP requests/responses during logging.
8//!
9//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
10//! [sensitive trait]: https://smithy.io/2.0/spec/documentation-traits.html#sensitive-trait
11
12pub mod headers;
13mod request;
14mod response;
15mod sensitive;
16pub mod uri;
17
18use http::{HeaderMap, StatusCode, Uri};
19pub use request::*;
20pub use response::*;
21pub use sensitive::*;
22
23use super::{MakeDebug, MakeDisplay};
24
25/// The string placeholder for redacted data.
26pub const REDACTED: &str = "{redacted}";
27
28/// An interface for providing [`MakeDebug`] and [`MakeDisplay`] for [`Request`](http::Request) and
29/// [`Response`](http::Response).
30pub trait Sensitivity {
31 /// The [`MakeDebug`] and [`MakeDisplay`] for the request [`HeaderMap`] and [`Uri`].
32 type RequestFmt: for<'a> MakeDebug<&'a HeaderMap> + for<'a> MakeDisplay<&'a Uri>;
33 /// The [`MakeDebug`] and [`MakeDisplay`] for the response [`HeaderMap`] and [`StatusCode`].
34 type ResponseFmt: for<'a> MakeDebug<&'a HeaderMap> + MakeDisplay<StatusCode>;
35
36 /// Returns the [`RequestFmt`](Sensitivity::RequestFmt).
37 fn request_fmt() -> Self::RequestFmt;
38
39 /// Returns the [`ResponseFmt`](Sensitivity::ResponseFmt).
40 fn response_fmt() -> Self::ResponseFmt;
41}