Skip to content

Commit

Permalink
docs: Polish README (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo committed Jan 25, 2024
1 parent cbb9225 commit 85d2de5
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion README.md
Expand Up @@ -9,7 +9,42 @@

## Quick Start

TODO
Init client with `HickoryResolver`.

```rust
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

Expand Down

0 comments on commit 85d2de5

Please sign in to comment.