1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

allow to override request's uri

This commit is contained in:
Nikolay Kim 2019-03-29 16:27:18 -07:00
parent 5eb3f1154e
commit e9bbde6832
2 changed files with 19 additions and 11 deletions

View File

@ -15,6 +15,8 @@
### Changed ### Changed
* Allow to override request's uri
* Export `ws` sub-module with websockets related types * Export `ws` sub-module with websockets related types

View File

@ -73,25 +73,31 @@ impl ClientRequest {
where where
Uri: HttpTryFrom<U>, Uri: HttpTryFrom<U>,
{ {
let mut err = None;
let mut head = RequestHead::default();
head.method = method;
match Uri::try_from(uri) {
Ok(uri) => head.uri = uri,
Err(e) => err = Some(e.into()),
}
ClientRequest { ClientRequest {
head,
err,
config, config,
head: RequestHead::default(),
err: None,
#[cfg(feature = "cookies")] #[cfg(feature = "cookies")]
cookies: None, cookies: None,
timeout: None, timeout: None,
default_headers: true, default_headers: true,
response_decompress: true, response_decompress: true,
} }
.method(method)
.uri(uri)
}
/// Set HTTP URI of request.
#[inline]
pub fn uri<U>(mut self, uri: U) -> Self
where
Uri: HttpTryFrom<U>,
{
match Uri::try_from(uri) {
Ok(uri) => self.head.uri = uri,
Err(e) => self.err = Some(e.into()),
}
self
} }
/// Set HTTP method of this request. /// Set HTTP method of this request.