#reqwest #http-client #netrc #client #http

reqwest-netrc

netrc support for Rust with support for reqwest

3 releases

0.1.2 Oct 20, 2024
0.1.1 Jan 20, 2024
0.1.0 Jan 20, 2024

#2026 in Network programming

Download history 228/week @ 2024-08-16 289/week @ 2024-08-23 160/week @ 2024-08-30 617/week @ 2024-09-06 340/week @ 2024-09-13 367/week @ 2024-09-20 459/week @ 2024-09-27 501/week @ 2024-10-04 466/week @ 2024-10-11 830/week @ 2024-10-18 525/week @ 2024-10-25 448/week @ 2024-11-01 251/week @ 2024-11-08 398/week @ 2024-11-15 511/week @ 2024-11-22 873/week @ 2024-11-29

2,083 downloads per month
Used in 4 crates (via warpgate)

MIT license

37KB
850 lines

netrc

A netrc library for Rust, with support for reqwest via reqwest-middleware.

reqwest-netrc

The reqwest-netrc crate is a middleware for reqwest to support the netrc file.

crates.io Documentation MIT licensed CI

Usage

To bring this crate into your repository, either add reqwest-netrc to your Cargo.toml, or run:

> cargo add reqwest-netrc

Example

The common scenario is to have a ~/.netrc file or the NETRC environement variable defined:

use reqwest::Client;
use reqwest_middleware::ClientBuilder;
use reqwest_netrc::NetrcMiddleware;

// ...

let client = ClientBuilder::new(Client::builder().build().unwrap())
    .with_init(NetrcMiddleware::new().unwrap())
    .build();

let res = client.get("https://domain.io/api/hello").send().await;

// ...

rust-netrc

The rust-netrc crate is a parser for the netrc files.

crates.io Documentation MIT licensed CI

Usage

To bring this crate into your repository, either add rust-netrc to your Cargo.toml, or run:

> cargo add rust-netrc

Example

use netrc::Netrc;

fn main() {
  let nrc = Netrc::new().unwrap();

  for (host, auth) in nrc.hosts {
      println!("{host}: {auth:?}");
  }
}

Contributing

Feedback and contributions are very welcome.

License

This project is licensed under MIT.

Dependencies

~5–16MB
~202K SLoC