From 9b6a93d72c45a494cada48034f726b027d68843d Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Sat, 17 Aug 2024 23:09:59 +0100 Subject: [PATCH] TryIntoHeaderValue for Uri --- actix-http/src/header/into_value.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/actix-http/src/header/into_value.rs b/actix-http/src/header/into_value.rs index 253900633..688580420 100644 --- a/actix-http/src/header/into_value.rs +++ b/actix-http/src/header/into_value.rs @@ -1,7 +1,7 @@ //! [`TryIntoHeaderValue`] trait and implementations. use bytes::Bytes; -use http::{header::InvalidHeaderValue, Error as HttpError, HeaderValue}; +use http::{header::InvalidHeaderValue, Error as HttpError, HeaderValue, Uri}; use mime::Mime; /// An interface for types that can be converted into a [`HeaderValue`]. @@ -129,3 +129,12 @@ impl TryIntoHeaderValue for Mime { HeaderValue::from_str(self.as_ref()) } } + +impl TryIntoHeaderValue for Uri { + type Error = InvalidHeaderValue; + + #[inline] + fn try_into_value(self) -> Result { + HeaderValue::from_str(&self.to_string()) + } +}