pub struct Request {
pub method: Method,
pub path: String,
pub headers: HashMap<String, String>,
pub body: Option<RequestBody>,
pub query: Option<HashMap<String, String>>,
pub auth: Option<Auth>,
}Expand description
HTTP request builder.
Fields§
§method: MethodHTTP method (GET, POST, etc.)
path: StringRequest path (absolute or relative to base_url)
headers: HashMap<String, String>Request headers
body: Option<RequestBody>Request body (JSON or bytes)
query: Option<HashMap<String, String>>Query parameters
auth: Option<Auth>Authentication override (if None, use client default)
Implementations§
Source§impl Request
impl Request
Sourcepub fn new(method: Method, path: impl Into<String>) -> Self
pub fn new(method: Method, path: impl Into<String>) -> Self
Creates a new request with the given method and path.
Sourcepub fn body(self, body: RequestBody) -> Self
pub fn body(self, body: RequestBody) -> Self
Sets the request body.
Sourcepub fn json_body<T: Serialize>(self, value: &T) -> Result<Self, Error>
pub fn json_body<T: Serialize>(self, value: &T) -> Result<Self, Error>
Sets the request body from a JSON-serializable value.
Sourcepub fn query_param(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn query_param( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a query parameter.
Sourcepub fn auth(self, auth: Auth) -> Self
pub fn auth(self, auth: Auth) -> Self
Sets authentication for this request (overrides client default).
Sourcepub fn bearer_token(self, token: impl Into<String>) -> Self
pub fn bearer_token(self, token: impl Into<String>) -> Self
Sets Bearer token authentication for this request.
Trait Implementations§
Auto Trait Implementations§
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