Struct tauri::api::http::HttpRequestBuilder
x3A;:HttpRequestBuilder,
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.
#
Examplesuse 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!");
}
}
#
Fieldsmethod: 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)
#
ImplementationsHttpRequestBuilder[src]#
implnew(method: impl Into<String>, url: impl Into<String>) -> Self[src]#
pub fnInitializes a new instance of the HttpRequestrequest_builder.
query(self, query: HashMap<String, String>) -> Self[src]#
pub fnSets the request parameters.
headers(self, headers: HashMap<String, String>) -> Self[src]#
pub fnSets the request headers.
body(self, body: Body) -> Self[src]#
pub fnSets the request body.
timeout(self, timeout: u64) -> Self[src]#
pub fnSets the general request timeout.
response_type(self, response_type: ResponseType) -> Self[src]#
pub fnSets the type of the response. Interferes with the way we read the response.
#
Trait ImplementationsDebug for HttpRequestBuilder[src]#
implfmt(&self, f: &mut Formatter<'_>) -> Result[src]#
fnFormats the value using the given formatter. Read more
Deserialize<'de> for HttpRequestBuilder[src]#
impl<'de>deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where __D: Deserializer<'de>,[src]#
fnDeserialize this value from the given Serde deserializer. Read more
#
Auto Trait ImplementationsRefUnwindSafe for HttpRequestBuilder#
implSend for HttpRequestBuilder#
implSync for HttpRequestBuilder#
implUnpin for HttpRequestBuilder#
implUnwindSafe for HttpRequestBuilder#
impl#
Blanket ImplementationsAny for T where T: 'static + ?Sized,[src]#
impl<T>type_id(&self) -> TypeId[src]#
pub fnGets the TypeId
of self
. Read more
Borrow<T> for T where T: ?Sized,[src]#
impl<T>borrow(&self) -> &T[src]#
pub fnImmutably borrows from an owned value. Read more
BorrowMut<T> for T where T: ?Sized,[src]#
impl<T>borrow_mut(&mut self) -> &mutT[src]#
pub fnMutably borrows from an owned value. Read more
CommandArg<'de, R> for D where R: Runtime, D: Deserialize<'de>,[src]#
impl<'de, D, R>from_command(CommandItem<'de, R>) -> Result<D, InvokeError>[src]#
pub fnDerives an instance of Self
from the CommandItem
. Read more
From<T> for T[src]#
impl<T>from(t: T) -> T[src]#
pub fnPerforms the conversion.
Into<U> for T where U: From<T>,[src]#
impl<T, U>into(self) -> U[src]#
pub fnPerforms the conversion.
TryFrom<U> for T where U: Into<T>,[src]#
impl<T, U>Error = Infallible#
typeThe type returned in the event of a conversion error.
try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]#
pub fnPerforms the conversion.
TryInto<U> for T where U: TryFrom<T>,[src]#
impl<T, U>Error = <U as TryFrom<T>>::Error#
typeThe type returned in the event of a conversion error.
try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]#
pub fnPerforms the conversion.