3 releases

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

#637 in Network programming

Download history 3400/week @ 2024-08-17 3265/week @ 2024-08-24 4158/week @ 2024-08-31 4209/week @ 2024-09-07 3107/week @ 2024-09-14 3181/week @ 2024-09-21 3358/week @ 2024-09-28 2761/week @ 2024-10-05 1371/week @ 2024-10-12 2690/week @ 2024-10-19 3145/week @ 2024-10-26 2714/week @ 2024-11-02 2255/week @ 2024-11-09 2376/week @ 2024-11-16 2694/week @ 2024-11-23 2923/week @ 2024-11-30

10,833 downloads per month
Used in 6 crates (3 directly)

MIT license

30KB
759 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

~1–11MB
~73K SLoC