diff options
| author | Fuwn <[email protected]> | 2023-04-06 08:34:24 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-06 08:34:24 +0000 |
| commit | 873cef6fbba01c99733c97378b5f001779604cf4 (patch) | |
| tree | 4dc531b2005740ec5048350ecdae7ba15836e058 /src/context | |
| parent | feat(cargo): bump 0.3.1 -> 0.3.2 (diff) | |
| download | windmark-873cef6fbba01c99733c97378b5f001779604cf4.tar.xz windmark-873cef6fbba01c99733c97378b5f001779604cf4.zip | |
fix(context): custom parameters format for easy lifetimes
Diffstat (limited to 'src/context')
| -rw-r--r-- | src/context/hook.rs | 13 | ||||
| -rw-r--r-- | src/context/route.rs | 12 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/context/hook.rs b/src/context/hook.rs index 6a4fe72..04ac816 100644 --- a/src/context/hook.rs +++ b/src/context/hook.rs @@ -16,31 +16,34 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only +use std::collections::HashMap; + use matchit::Params; use openssl::x509::X509; use url::Url; #[allow(clippy::module_name_repetitions)] #[derive(Clone)] -pub struct HookContext<'a> { +pub struct HookContext { pub peer_address: Option<std::net::SocketAddr>, pub url: Url, - pub params: Option<Params<'a, 'a>>, + pub params: Option<HashMap<String, String>>, pub certificate: Option<X509>, } -impl<'a> HookContext<'a> { +impl HookContext { #[must_use] pub fn new( peer_address: std::io::Result<std::net::SocketAddr>, url: Url, - params: Option<Params<'a, 'a>>, + params: Option<Params<'_, '_>>, certificate: Option<X509>, ) -> Self { Self { peer_address: peer_address.ok(), url, - params, + params: params + .map(|parameters| crate::utilities::params_to_hashmap(¶meters)), certificate, } } diff --git a/src/context/route.rs b/src/context/route.rs index 9ff0b03..a39ad0b 100644 --- a/src/context/route.rs +++ b/src/context/route.rs @@ -16,31 +16,33 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only +use std::collections::HashMap; + use matchit::Params; use openssl::x509::X509; use url::Url; #[allow(clippy::module_name_repetitions)] #[derive(Clone)] -pub struct RouteContext<'a> { +pub struct RouteContext { pub peer_address: Option<std::net::SocketAddr>, pub url: Url, - pub params: Params<'a, 'a>, + pub params: HashMap<String, String>, pub certificate: Option<X509>, } -impl<'a> RouteContext<'a> { +impl RouteContext { #[must_use] pub fn new( peer_address: std::io::Result<std::net::SocketAddr>, url: Url, - params: Params<'a, 'a>, + params: &Params<'_, '_>, certificate: Option<X509>, ) -> Self { Self { peer_address: peer_address.ok(), url, - params, + params: crate::utilities::params_to_hashmap(params), certificate, } } |