14 releases

0.3.3 May 22, 2023
0.3.2 Dec 8, 2022
0.2.0 Nov 14, 2022
0.1.9 Oct 20, 2022
0.1.8 Sep 20, 2022

#1398 in Parser implementations

40 downloads per month
Used in spacex_sdk

MIT license

13KB
237 lines

jwfetch

Package reqwest with trace.

Example

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.

Dependencies

~12–23MB
~424K SLoC