From 873cef6fbba01c99733c97378b5f001779604cf4 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 6 Apr 2023 08:34:24 +0000 Subject: fix(context): custom parameters format for easy lifetimes --- src/context/hook.rs | 13 ++++++++----- src/context/route.rs | 12 +++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'src/context') 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 // 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, pub url: Url, - pub params: Option>, + pub params: Option>, pub certificate: Option, } -impl<'a> HookContext<'a> { +impl HookContext { #[must_use] pub fn new( peer_address: std::io::Result, url: Url, - params: Option>, + params: Option>, certificate: Option, ) -> 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 // 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, pub url: Url, - pub params: Params<'a, 'a>, + pub params: HashMap, pub certificate: Option, } -impl<'a> RouteContext<'a> { +impl RouteContext { #[must_use] pub fn new( peer_address: std::io::Result, url: Url, - params: Params<'a, 'a>, + params: &Params<'_, '_>, certificate: Option, ) -> Self { Self { peer_address: peer_address.ok(), url, - params, + params: crate::utilities::params_to_hashmap(params), certificate, } } -- cgit v1.2.3