diff options
| author | Fuwn <[email protected]> | 2023-04-06 07:38:27 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-06 07:38:27 +0000 |
| commit | 50601e3248865f4c4735ea44ae0ebd253be96397 (patch) | |
| tree | b3ce54c417a8996e51e6e92c7bbf2c85e4ca7c3d /src/context | |
| parent | refactor(router): simplify context creation (diff) | |
| download | windmark-50601e3248865f4c4735ea44ae0ebd253be96397.tar.xz windmark-50601e3248865f4c4735ea44ae0ebd253be96397.zip | |
feat(context): bring back peer address
Diffstat (limited to 'src/context')
| -rw-r--r-- | src/context/error.rs | 12 | ||||
| -rw-r--r-- | src/context/hook.rs | 11 | ||||
| -rw-r--r-- | src/context/route.rs | 11 |
3 files changed, 23 insertions, 11 deletions
diff --git a/src/context/error.rs b/src/context/error.rs index 7e02b1a..3540a45 100644 --- a/src/context/error.rs +++ b/src/context/error.rs @@ -22,14 +22,20 @@ use url::Url; #[allow(clippy::module_name_repetitions)] #[derive(Clone)] pub struct ErrorContext { - pub url: Url, - pub certificate: Option<X509>, + pub peer_address: Option<std::net::SocketAddr>, + pub url: Url, + pub certificate: Option<X509>, } impl ErrorContext { #[must_use] - pub const fn new(url: Url, certificate: Option<X509>) -> Self { + pub fn new( + peer_address: std::io::Result<std::net::SocketAddr>, + url: Url, + certificate: Option<X509>, + ) -> Self { Self { + peer_address: peer_address.ok(), url, certificate, } diff --git a/src/context/hook.rs b/src/context/hook.rs index 94a6908..6a4fe72 100644 --- a/src/context/hook.rs +++ b/src/context/hook.rs @@ -23,19 +23,22 @@ use url::Url; #[allow(clippy::module_name_repetitions)] #[derive(Clone)] pub struct HookContext<'a> { - pub url: Url, - pub params: Option<Params<'a, 'a>>, - pub certificate: Option<X509>, + pub peer_address: Option<std::net::SocketAddr>, + pub url: Url, + pub params: Option<Params<'a, 'a>>, + pub certificate: Option<X509>, } impl<'a> HookContext<'a> { #[must_use] - pub const fn new( + pub fn new( + peer_address: std::io::Result<std::net::SocketAddr>, url: Url, params: Option<Params<'a, 'a>>, certificate: Option<X509>, ) -> Self { Self { + peer_address: peer_address.ok(), url, params, certificate, diff --git a/src/context/route.rs b/src/context/route.rs index b3b105d..9ff0b03 100644 --- a/src/context/route.rs +++ b/src/context/route.rs @@ -23,19 +23,22 @@ use url::Url; #[allow(clippy::module_name_repetitions)] #[derive(Clone)] pub struct RouteContext<'a> { - pub url: Url, - pub params: Params<'a, 'a>, - pub certificate: Option<X509>, + pub peer_address: Option<std::net::SocketAddr>, + pub url: Url, + pub params: Params<'a, 'a>, + pub certificate: Option<X509>, } impl<'a> RouteContext<'a> { #[must_use] - pub const fn new( + pub fn new( + peer_address: std::io::Result<std::net::SocketAddr>, url: Url, params: Params<'a, 'a>, certificate: Option<X509>, ) -> Self { Self { + peer_address: peer_address.ok(), url, params, certificate, |