1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
use http::Method;
use super::request::RequestBuilder;
/// A type that can carry settings over multiple requests. The settings applied to the
/// `TestClient` are applied to every request created from this `TestClient`.
#[derive(Debug, Default)]
pub struct TestClient;
impl TestClient {
/// Create a new `RequestBuilder` with the GET method and this TestClient's settings applied on it.
pub fn get(url: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(url, Method::GET)
}
/// Create a new `RequestBuilder` with the POST method and this TestClient's settings applied on it.
pub fn post(url: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(url, Method::POST)
}
/// Create a new `RequestBuilder` with the PUT method and this TestClient's settings applied on it.
pub fn put(url: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(url, Method::PUT)
}
/// Create a new `RequestBuilder` with the DELETE method and this TestClient's settings applied on it.
pub fn delete(url: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(url, Method::DELETE)
}
/// Create a new `RequestBuilder` with the HEAD method and this TestClient's settings applied on it.
pub fn head(url: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(url, Method::HEAD)
}
/// Create a new `RequestBuilder` with the OPTIONS method and this TestClient's settings applied on it.
pub fn options(url: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(url, Method::OPTIONS)
}
/// Create a new `RequestBuilder` with the PATCH method and this TestClient's settings applied on it.
pub fn patch(url: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(url, Method::PATCH)
}
/// Create a new `RequestBuilder` with the TRACE method and this TestClient's settings applied on it.
pub fn trace(url: impl AsRef<str>) -> RequestBuilder {
RequestBuilder::new(url, Method::TRACE)
}
}