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

rust-netrc

netrc support for Rust with support for reqwest

2 releases

0.1.1 Jan 20, 2024
0.1.0 Jan 20, 2024

#1636 in Network programming

Download history 988/week @ 2024-03-14 1992/week @ 2024-03-21 2455/week @ 2024-03-28 1973/week @ 2024-04-04 1331/week @ 2024-04-11 1998/week @ 2024-04-18 2291/week @ 2024-04-25 1787/week @ 2024-05-02 2037/week @ 2024-05-09 2401/week @ 2024-05-16 2380/week @ 2024-05-23 1331/week @ 2024-05-30 2232/week @ 2024-06-06 1840/week @ 2024-06-13 1566/week @ 2024-06-20 1586/week @ 2024-06-27

7,629 downloads per month
Used in reqwest-netrc

MIT license

29KB
751 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

~265–720KB
~17K SLoC