| Crates.io | reqwest-netrc |
| lib.rs | reqwest-netrc |
| version | 0.1.3 |
| created_at | 2024-01-20 21:38:33.677934+00 |
| updated_at | 2025-02-09 14:51:12.540428+00 |
| description | netrc support for Rust with support for reqwest |
| homepage | |
| repository | https://github.com/gribouille/netrc |
| max_upload_size | |
| id | 1106827 |
| size | 8,677 |
A netrc library for Rust, with support for reqwest via reqwest-middleware.
The reqwest-netrc crate is a middleware for reqwest
to support the netrc file.
To bring this crate into your repository, either add reqwest-netrc to your
Cargo.toml, or run:
> cargo add reqwest-netrc
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;
// ...
The rust-netrc crate is a parser for the netrc files.
To bring this crate into your repository, either add rust-netrc to your
Cargo.toml, or run:
> cargo add rust-netrc
use netrc::Netrc;
fn main() {
let nrc = Netrc::new().unwrap();
for (host, auth) in nrc.hosts {
println!("{host}: {auth:?}");
}
}
Feedback and contributions are very welcome.
This project is licensed under MIT.