Crates.io | reqwest-hickory-resolver |
lib.rs | reqwest-hickory-resolver |
version | 0.1.0 |
source | src |
created_at | 2024-01-25 11:08:01.967064 |
updated_at | 2024-05-08 08:50:54.471252 |
description | hickory resolver support for reqwest |
homepage | |
repository | https://github.com/Xuanwo/reqwest-hickory-resolver |
max_upload_size | |
id | 1113691 |
size | 25,736 |
reqwest-hickory-resolver
is the resolver for reqwest based on hickory-dns
.
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(())
}
Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.
Submit issues for bug report or asking questions in discussion.
This project is based on reqwest's TrustDnsResolver
.