From 735bcff54fc7cf2bf9b7007f4f7926fed0db3ee9 Mon Sep 17 00:00:00 2001 From: Vika Date: Fri, 15 Apr 2022 07:45:55 +0300 Subject: Cargo.toml: add reqwest It's an advanced HTTP client that can do more than vanilla Hyper does. --- src/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 8e610e1..c69a6c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,6 +96,7 @@ async fn main() { } }; + // TODO remove this and see what screams to replace it with reqwest let http_client: hyper::Client>, hyper::Body> = { let builder = hyper::Client::builder(); let https = hyper_rustls::HttpsConnectorBuilder::new() @@ -107,6 +108,22 @@ async fn main() { builder.build(https) }; + // This thing handles redirects automatically but is type-incompatible with hyper::Client + // Bonus: less generics to be aware of, this thing hides its complexity + let http: reqwest::Client = { + #[allow(unused_mut)] + let mut builder = reqwest::Client::builder() + .user_agent(concat!( + env!("CARGO_PKG_NAME"), + "/", + env!("CARGO_PKG_VERSION") + )); + // TODO add a root certificate if there's an environment variable pointing at it + //builder = builder.add_root_certificate(reqwest::Certificate::from_pem(todo!())); + + builder.build().unwrap() + }; + if backend_uri.starts_with("redis") { println!("The Redis backend is deprecated."); std::process::exit(1); -- cgit 1.4.1