mirror of
https://github.com/actix/actix-web.git
synced 2025-01-31 03:18:07 +00:00
TryIntoHeaderValue for Uri
This commit is contained in:
parent
b4f8bda032
commit
9b6a93d72c
1 changed files with 10 additions and 1 deletions
|
@ -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, Self::Error> {
|
||||
HeaderValue::from_str(&self.to_string())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue