pub struct Request;Implementations§
Source§impl Request
请求封装类
impl Request
请求封装类
Sourcepub async fn head(
url: &str,
query: Option<&HashMap<String, String>>,
headers: Option<&HashMap<String, String>>,
) -> Result<Response, Response>
pub async fn head( url: &str, query: Option<&HashMap<String, String>>, headers: Option<&HashMap<String, String>>, ) -> Result<Response, Response>
send Head request
§Examples
use rust_qcos::request::Request;
use std::collections::HashMap;
async {
let mut headers = HashMap::new();
headers.insert("x-test-header".to_string(), "test-header".to_string());
Request::head("https://www.baiduc.com", None, Some(&headers)).await;
};Sourcepub async fn get(
url: &str,
query: Option<&HashMap<String, String>>,
headers: Option<&HashMap<String, String>>,
) -> Result<Response, Response>
pub async fn get( url: &str, query: Option<&HashMap<String, String>>, headers: Option<&HashMap<String, String>>, ) -> Result<Response, Response>
send get request
§Examples
use rust_qcos::request::Request;
use std::collections::HashMap;
async {
let mut headers = HashMap::new();
headers.insert("x-test-header".to_string(), "test-header".to_string());
Request::get("https://www.baiduc.com", None, Some(&headers)).await;
};Sourcepub async fn post<T: Into<Body>>(
url: &str,
query: Option<&HashMap<String, String>>,
headers: Option<&HashMap<String, String>>,
form: Option<&HashMap<&str, Value>>,
json: Option<&HashMap<&str, Value>>,
body_data: Option<T>,
) -> Result<Response, Response>
pub async fn post<T: Into<Body>>( url: &str, query: Option<&HashMap<String, String>>, headers: Option<&HashMap<String, String>>, form: Option<&HashMap<&str, Value>>, json: Option<&HashMap<&str, Value>>, body_data: Option<T>, ) -> Result<Response, Response>
send post request
§Examples
use reqwest::Body;
use rust_qcos::request::Request;
use std::collections::HashMap;
use serde_json::json;
async {
let mut form = HashMap::new();
form.insert("hello", json!(1i16));
form.insert("hello1", json!("world"));
let mut json = HashMap::new();
json.insert("hello", json!(1i64));
json.insert("hello_json", json!("world"));
json.insert("data", json!(vec![1u8, 2u8, 3u8] as Vec<u8>));
let resp = Request::post(
"https://www.baidu.com",
None,
None,
Some(&form),
Some(&json),
None as Option<Body>,
).await;
};Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin 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