about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-04-15 07:45:55 +0300
committerVika <vika@fireburn.ru>2022-04-15 07:45:55 +0300
commit735bcff54fc7cf2bf9b7007f4f7926fed0db3ee9 (patch)
tree38c91d2c46d3f0811c0bb63ff1cbd0d0ae016a61 /src
parent2b89b35c0da959295fe9c90f62b0f94c617b8e31 (diff)
downloadkittybox-735bcff54fc7cf2bf9b7007f4f7926fed0db3ee9.tar.zst
Cargo.toml: add reqwest
It's an advanced HTTP client that can do more than vanilla Hyper does.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs17
1 files changed, 17 insertions, 0 deletions
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<HttpsConnector<HttpConnector<GaiResolver>>, 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);