#http-request #netrc #http-client

reqwest-netrc

netrc support for Rust with support for reqwest

4 releases

0.1.3 Feb 9, 2025
0.1.2 Oct 20, 2024
0.1.1 Jan 20, 2024
0.1.0 Jan 20, 2024

#1515 in Network programming

Download history 467/week @ 2024-12-21 660/week @ 2024-12-28 1510/week @ 2025-01-04 1363/week @ 2025-01-11 2130/week @ 2025-01-18 845/week @ 2025-01-25 1239/week @ 2025-02-01 2292/week @ 2025-02-08 1464/week @ 2025-02-15 2202/week @ 2025-02-22 2502/week @ 2025-03-01 2455/week @ 2025-03-08 1654/week @ 2025-03-15 2368/week @ 2025-03-22 1717/week @ 2025-03-29 1013/week @ 2025-04-05

7,115 downloads per month
Used in 6 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–20MB
~209K SLoC