3 releases

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

#624 in Network programming

Download history 3134/week @ 2024-10-24 2761/week @ 2024-10-31 2350/week @ 2024-11-07 2446/week @ 2024-11-14 2601/week @ 2024-11-21 3132/week @ 2024-11-28 2935/week @ 2024-12-05 3032/week @ 2024-12-12 2790/week @ 2024-12-19 2158/week @ 2024-12-26 3025/week @ 2025-01-02 4685/week @ 2025-01-09 3819/week @ 2025-01-16 4003/week @ 2025-01-23 3969/week @ 2025-01-30 4794/week @ 2025-02-06

17,147 downloads per month
Used in 11 crates (4 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–12MB
~72K SLoC