scuffle_http/extensions.rs
1//! HTTP extensions that this crate provides.
2
3use std::ops::Deref;
4
5/// This extension is always present on the request and contains the remote address of the client.
6#[derive(Clone, Debug)]
7pub struct ClientAddr(pub std::net::SocketAddr);
8
9impl Deref for ClientAddr {
10 type Target = std::net::SocketAddr;
11
12 fn deref(&self) -> &Self::Target {
13 &self.0
14 }
15}
16
17/// This extension is present on the request when the client has provided one or multiple TLS client
18/// certificates.
19#[derive(Clone, Debug)]
20#[cfg(feature = "tls-rustls")]
21pub struct ClientIdentity(pub std::sync::Arc<Vec<tokio_rustls::rustls::pki_types::CertificateDer<'static>>>);
22
23#[cfg(feature = "tls-rustls")]
24impl Deref for ClientIdentity {
25 type Target = std::sync::Arc<Vec<tokio_rustls::rustls::pki_types::CertificateDer<'static>>>;
26
27 fn deref(&self) -> &Self::Target {
28 &self.0
29 }
30}