Skip to main content

custom_protocol_http/
trace.rs

1//! What this crate reports, and the only place its `tracing` feature is `cfg`ed.
2//!
3//! Decisions only. Nothing here reads a body, a header value or a query string:
4//! a refusal is described by what was refused, which is a URL's authority or a
5//! capability's name, and neither is a secret.
6
7#[cfg(feature = "tower")]
8use crate::{Denial, Unsupported};
9
10#[cfg(feature = "tower")]
11pub(crate) fn refused_foreign_origin(denial: &Denial) {
12    #[cfg(feature = "tracing")]
13    tracing::warn!(reason = %denial, "refused a request for another origin");
14    #[cfg(not(feature = "tracing"))]
15    let _ = denial;
16}
17
18#[cfg(feature = "tower")]
19pub(crate) fn refused_unsupported(unsupported: &Unsupported) {
20    #[cfg(feature = "tracing")]
21    tracing::warn!(capability = %unsupported, "refused a response this transport cannot carry");
22    #[cfg(not(feature = "tracing"))]
23    let _ = unsupported;
24}
25
26/// The platform origin is the one thing invisible from inside the application,
27/// and the first thing worth knowing when a route behaves differently on
28/// Windows.
29///
30/// Taken unrendered, so it is spelled out only when somebody is listening.
31pub(crate) fn rewrote_origin(from: &crate::Origin, path: &str) {
32    #[cfg(feature = "tracing")]
33    tracing::debug!(
34        platform_origin = %from,
35        path,
36        "rewrote a request onto the canonical origin"
37    );
38    #[cfg(not(feature = "tracing"))]
39    let _ = (from, path);
40}