Struct tauri::api::http::HttpRequestBuilder [−][src]
pub struct HttpRequestBuilder { pub method: String, pub url: String, pub query: Option<HashMap<String, String>>, pub headers: Option<HashMap<String, String>>, pub body: Option<Body>, pub timeout: Option<u64>, pub response_type: Option<ResponseType>, }
Expand description
The builder for a HTTP request.
Examples
use tauri::api::http::{ HttpRequestBuilder, ResponseType, ClientBuilder }; async fn run() { let client = ClientBuilder::new() .max_redirections(3) .build() .unwrap(); let mut request_builder = HttpRequestBuilder::new("GET", "http://example.com"); let request = request_builder.response_type(ResponseType::Text); if let Ok(response) = client.send(request).await { println!("got response"); } else { println!("Something Happened!"); } }
Fields
method: String
The request method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, CONNECT or TRACE)
url: String
The request URL
query: Option<HashMap<String, String>>
The request query params
headers: Option<HashMap<String, String>>
The request headers
body: Option<Body>
The request body
timeout: Option<u64>
Timeout for the whole request
response_type: Option<ResponseType>
The response type (defaults to Json)
Implementations
Initializes a new instance of the HttpRequestrequest_builder.
Sets the type of the response. Interferes with the way we read the response.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for HttpRequestBuilder
impl Send for HttpRequestBuilder
impl Sync for HttpRequestBuilder
impl Unpin for HttpRequestBuilder
impl UnwindSafe for HttpRequestBuilder
Blanket Implementations
Mutably borrows from an owned value. Read more
Derives an instance of Self
from the CommandItem
. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more