Compare commits

...

3 Commits

Author SHA1 Message Date
Jeremiah Senkpiel b1fc45c837
Merge pull request #308 from utsavm9/main
RequestBuilder from Client and user-provided method
2021-06-30 10:50:38 -07:00
Utsav Munendra 84c46d14d9 Fix doc code of client response() 2021-06-29 16:12:12 -07:00
Utsav Munendra e20eb8f403 RequestBuilder from Client and user-provided method 2021-06-24 18:41:17 -07:00
1 changed files with 24 additions and 0 deletions

View File

@ -523,6 +523,30 @@ impl Client {
RequestBuilder::new(Method::Patch, self.url(uri)).with_client(self.clone())
}
/// Perform a HTTP request with the given verb using the `Client` connection.
///
/// # Panics
///
/// This will panic if a malformed URL is passed.
///
/// # Errors
///
/// Returns errors from the middleware, http backend, and network sockets.
///
/// # Examples
/// ```no_run
/// # #[async_std::main]
/// # async fn main() -> surf::Result<()> {
/// use http_types::Method;
/// let client = surf::client();
/// let req = client.request(Method::Get, "http://httpbin.org/get");
/// let res = client.send(req).await?;
/// # Ok(()) }
/// ```
pub fn request(&self, verb: Method, uri: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(verb, self.url(uri)).with_client(self.clone())
}
/// Sets the base URL for this client. All request URLs will be relative to this URL.
///
/// Note: a trailing slash is significant.