No need to clone the Host header
This commit is contained in:
parent
b876bb9c84
commit
2c1571881e
1 changed files with 8 additions and 4 deletions
|
@ -24,12 +24,16 @@ impl<'a, 'r> FromRequest<'a, 'r> for IsPlaintextRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HostHeader(pub Option<String>);
|
/// Gets the Host header from the request.
|
||||||
|
///
|
||||||
|
/// The inner value of this `HostHeader` will be `None` if there was no Host header
|
||||||
|
/// on the request.
|
||||||
|
pub struct HostHeader<'a>(pub Option<&'a str>);
|
||||||
|
|
||||||
impl<'a, 'r> FromRequest<'a, 'r> for HostHeader {
|
impl<'a, 'r> FromRequest<'a, 'r> for HostHeader<'a> {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn from_request(request: &'a Request<'r>) -> Outcome<HostHeader, ()> {
|
fn from_request(request: &'a Request<'r>) -> Outcome<HostHeader<'a>, ()> {
|
||||||
Outcome::Success(HostHeader(request.headers().get_one("Host").map(|h| h.to_string())))
|
Outcome::Success(HostHeader(request.headers().get_one("Host")))
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue