3 unstable releases
0.1.0 | May 8, 2024 |
---|---|
0.0.2 | Jan 25, 2024 |
0.0.1 | Jan 25, 2024 |
#1489 in Command line utilities
4,246 downloads per month
10KB
reqwest-hickory-resolver
reqwest-hickory-resolver
is the resolver for reqwest based on hickory-dns
.
Quick Start
Init client with HickoryResolver
.
use std::sync::Arc;
use reqwest::ClientBuilder;
use reqwest_hickory_resolver::HickoryResolver;
fn init_with_hickory_resolver() -> reqwest::Result<()> {
let mut builder = ClientBuilder::new();
builder = builder.dns_resolver(Arc::new(HickoryResolver::default()));
builder.build()?;
Ok(())
}
HickoryResolver has cache support, we can share the same resolver across different client for better performance.
use std::sync::Arc;
use once_cell::sync::Lazy;
use reqwest::ClientBuilder;
use reqwest_hickory_resolver::HickoryResolver;
static GLOBAL_RESOLVER: Lazy<Arc<HickoryResolver>> =
Lazy::new(|| Arc::new(HickoryResolver::default()));
fn init_with_hickory_resolver() -> reqwest::Result<()> {
let mut builder = ClientBuilder::new();
builder = builder.dns_resolver(GLOBAL_RESOLVER.clone());
builder.build()?;
Ok(())
}
Contributing
Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.
Getting help
Submit issues for bug report or asking questions in discussion.
Acknowledgements
This project is based on reqwest's TrustDnsResolver
.
License
Licensed under Apache License, Version 2.0.Dependencies
~9–20MB
~282K SLoC