author | Jordan Johnson-Doyle <jordan@doyle.la> | 2019-02-12 1:22:47.0 +00:00:00 |
---|---|---|
committer | Jordan Johnson-Doyle <jordan@doyle.la> | 2019-02-12 1:22:47.0 +00:00:00 |
commit | 2c1571881e9eb7236a41adc3df61726eb4008aa0 [patch] |
|
tree | 1d18b9ef06941a30a2fa25120f8fa5390d4de5ce |
|
parent | b876bb9c84cc6823d7a615b76c2ce7d39385c08b |
|
download | 2c1571881e9eb7236a41adc3df61726eb4008aa0.tar.gz |
No need to clone the Host header
Diff
src/params.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/params.rs b/src/params.rs index 2e08228..e8b7930 100644 --- a/src/params.rs +++ a/src/params.rs @@ -24,12 +24,16 @@ } } 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 = (); fn from_request(request: &'a Request<'r>) -> Outcome<HostHeader, ()> { Outcome::Success(HostHeader(request.headers().get_one("Host").map(|h| h.to_string()))) fn from_request(request: &'a Request<'r>) -> Outcome<HostHeader<'a>, ()> { Outcome::Success(HostHeader(request.headers().get_one("Host"))) } }