pub struct ClientRequest {
pub url: Url,
pub headers: HeaderMap,
pub method: Method,
pub extensions: Extensions,
}Fields§
§url: Url§headers: HeaderMap§method: Method§extensions: ExtensionsImplementations§
Source§impl ClientRequest
impl ClientRequest
Sourcepub fn new(method: Method, path: String, params: &impl Serialize) -> Self
pub fn new(method: Method, path: String, params: &impl Serialize) -> Self
Create a new ClientRequest with the given method, url path, and query parameters.
pub fn url(&self) -> &Url
Sourcepub fn extend_query(self, query: &impl Serialize) -> Self
pub fn extend_query(self, query: &impl Serialize) -> Self
Extend the query parameters of this request with the given serialzable struct.
This will use serde_qs to serialize the struct into query parameters. serde_qs has various
restrictions - make sure to read its documentation!
Sourcepub fn header(
self,
name: impl TryInto<HeaderName, Error = impl Display>,
value: impl TryInto<HeaderValue, Error = impl Display>,
) -> Result<Self, RequestError>
pub fn header( self, name: impl TryInto<HeaderName, Error = impl Display>, value: impl TryInto<HeaderValue, Error = impl Display>, ) -> Result<Self, RequestError>
Add a Header to this Request.
Sourcepub fn typed_header<H: Header>(self, header: H) -> Self
pub fn typed_header<H: Header>(self, header: H) -> Self
Add a Header to this Request.
Sourcepub fn new_reqwest_client() -> Client
pub fn new_reqwest_client() -> Client
Creates a new reqwest client with cookies set
Sourcepub fn new_reqwest_request(&self) -> RequestBuilder
pub fn new_reqwest_request(&self) -> RequestBuilder
Creates a new reqwest request builder with the method, url, and headers set from this ClientRequest
Using this method attaches X-Request-Client: dioxus header to the request.
Sourcepub async fn send_multipart(
self,
form: &FormData,
) -> Result<ClientResponse, RequestError>
pub async fn send_multipart( self, form: &FormData, ) -> Result<ClientResponse, RequestError>
Sends the request with multipart/form-data body constructed from the given FormData.
pub async fn send_form( self, data: &impl Serialize, ) -> Result<ClientResponse, RequestError>
Sourcepub async fn send_empty_body(self) -> Result<ClientResponse, RequestError>
pub async fn send_empty_body(self) -> Result<ClientResponse, RequestError>
Sends the request with an empty body.
pub async fn send_raw_bytes( self, bytes: impl Into<Bytes>, ) -> Result<ClientResponse, RequestError>
Sourcepub async fn send_text(
self,
text: impl Into<String> + Into<Bytes>,
) -> Result<ClientResponse, RequestError>
pub async fn send_text( self, text: impl Into<String> + Into<Bytes>, ) -> Result<ClientResponse, RequestError>
Sends text data with the text/plain; charset=utf-8 content type.
Sourcepub async fn send_json(
self,
json: &impl Serialize,
) -> Result<ClientResponse, RequestError>
pub async fn send_json( self, json: &impl Serialize, ) -> Result<ClientResponse, RequestError>
Sends JSON data with the application/json content type.