pub struct Request {
pub url: String,
pub method: String,
pub headers: HashMap<String, String>,
pub body: Option<String>,
pub timeout: Option<Duration>,
}Expand description
Generic HTTP request passed through the transport abstraction.
Fields§
§url: String§method: String§headers: HashMap<String, String>§body: Option<String>§timeout: Option<Duration>Overrides the transport’s default timeout for this request.
NativeHttpClient honours it. GholaHttpClient ignores it: the
request to the sidecar uses the Ghola client’s own timeout.
Implementations§
Source§impl Request
impl Request
Sourcepub fn post_json(url: &str, body: impl Into<String>) -> Self
pub fn post_json(url: &str, body: impl Into<String>) -> Self
Convenience constructor for a POST request with a JSON body.
Sourcepub fn with_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a header to the request.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets a timeout for this request only.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Request
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more