jwfetch

Crates.iojwfetch
lib.rsjwfetch
version0.3.3
sourcesrc
created_at2022-09-12 13:43:18.836632
updated_at2023-05-22 08:25:24.838733
descriptionpackage reqwest with trace
homepage
repositoryhttps://github.com/jiawei397/rust_jwfetch
max_upload_size
id663761
size43,638
jia wei (jiawei397)

documentation

https://docs.rs/jwfetch

README

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.

Commit count: 30

cargo fmt