From 50601e3248865f4c4735ea44ae0ebd253be96397 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 6 Apr 2023 07:38:27 +0000 Subject: feat(context): bring back peer address --- src/context/error.rs | 12 +++++++++--- src/context/hook.rs | 11 +++++++---- src/context/route.rs | 11 +++++++---- 3 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src/context') 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, + pub peer_address: Option, + pub url: Url, + pub certificate: Option, } impl ErrorContext { #[must_use] - pub const fn new(url: Url, certificate: Option) -> Self { + pub fn new( + peer_address: std::io::Result, + url: Url, + certificate: Option, + ) -> 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>, - pub certificate: Option, + pub peer_address: Option, + pub url: Url, + pub params: Option>, + pub certificate: Option, } impl<'a> HookContext<'a> { #[must_use] - pub const fn new( + pub fn new( + peer_address: std::io::Result, url: Url, params: Option>, certificate: Option, ) -> 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, + pub peer_address: Option, + pub url: Url, + pub params: Params<'a, 'a>, + pub certificate: Option, } impl<'a> RouteContext<'a> { #[must_use] - pub const fn new( + pub fn new( + peer_address: std::io::Result, url: Url, params: Params<'a, 'a>, certificate: Option, ) -> Self { Self { + peer_address: peer_address.ok(), url, params, certificate, -- cgit v1.2.3