reqwest-hickory-resolver

Crates.ioreqwest-hickory-resolver
lib.rsreqwest-hickory-resolver
version0.1.0
sourcesrc
created_at2024-01-25 11:08:01.967064
updated_at2024-05-08 08:50:54.471252
descriptionhickory resolver support for reqwest
homepage
repositoryhttps://github.com/Xuanwo/reqwest-hickory-resolver
max_upload_size
id1113691
size25,736
Xuanwo (Xuanwo)

documentation

https://docs.rs/reqwest-hickory-resolver

README

reqwest-hickory-resolver   Build Status Latest Version

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.
Commit count: 10

cargo fmt