mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-07-14 16:25:06 +00:00
Extract client creation to a single place
This commit is contained in:
parent
b268c3dd1c
commit
155109dea1
5 changed files with 33 additions and 23 deletions
|
@ -12,7 +12,7 @@ use regex::Regex;
|
|||
use reqwest::{blocking::Client, blocking::Response, header, Url};
|
||||
use rocket::{http::ContentType, http::Cookie, response::Content, Route};
|
||||
|
||||
use crate::{error::Error, util::Cached, CONFIG};
|
||||
use crate::{error::Error, util::{Cached, get_reqwest_client_builder}, CONFIG};
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![icon]
|
||||
|
@ -28,11 +28,11 @@ static CLIENT: Lazy<Client> = Lazy::new(|| {
|
|||
default_headers.insert(header::ACCEPT, header::HeaderValue::from_static("text/html,application/xhtml+xml,application/xml; q=0.9,image/webp,image/apng,*/*;q=0.8"));
|
||||
|
||||
// Reuse the client between requests
|
||||
Client::builder()
|
||||
get_reqwest_client_builder()
|
||||
.timeout(Duration::from_secs(CONFIG.icon_download_timeout()))
|
||||
.default_headers(default_headers)
|
||||
.build()
|
||||
.unwrap()
|
||||
.expect("Failed to build icon client")
|
||||
});
|
||||
|
||||
// Build Regex only once since this takes a lot of time.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue