1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 13:29:24 +00: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
* Allow to override request's uri
* Export `ws` sub-module with websockets related types

View file

@ -73,25 +73,31 @@ impl ClientRequest {
where
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 {
head,
err,
config,
head: RequestHead::default(),
err: None,
#[cfg(feature = "cookies")]
cookies: None,
timeout: None,
default_headers: 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.