Crates.io | jwfetch |
lib.rs | jwfetch |
version | 0.3.3 |
source | src |
created_at | 2022-09-12 13:43:18.836632 |
updated_at | 2023-05-22 08:25:24.838733 |
description | package reqwest with trace |
homepage | |
repository | https://github.com/jiawei397/rust_jwfetch |
max_upload_size | |
id | 663761 |
size | 43,638 |
Package reqwest with trace.
run example use cargo run --example simple
:
use jwfetch::{request, get, post, BaseRequestConfig, RequestConfig, FetchError, ActixHeaderMap, Method};
use serde_derive::{Deserialize, Serialize};
#[derive(Deserialize, Debug, Serialize, Clone)]
pub struct UserInfo {
pub id: String,
pub avatar: String,
}
pub async fn get_user_info(origin_headers: ActixHeaderMap) -> Result<UserInfo, FetchError> {
request::<UserInfo>(RequestConfig {
url: "user/userinfo".to_string(),
method: Method::GET,
base_url: Some("https://api.github.com/api/".to_string()),
origin_headers: Some(origin_headers),
headers: None,
data: None,
timeout: None,
extra_header_keys: Some(vec!["user-agent", "cookie", "referer"]),
})
.await
}
Or you can use get
, post
with BaseRequestConfig
instead.