diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs index 0234abc..ed8c8e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,15 @@ use log::{debug, error, info}; use std::{convert::Infallible, env, time::Duration}; use url::Url; -use hyper::client::{HttpConnector,connect::dns::GaiResolver}; -use hyper_rustls::HttpsConnector; use warp::{Filter, host::Authority}; #[tokio::main] async fn main() { + // TODO turn into a feature so I can enable and disable it #[cfg(debug_assertions)] console_subscriber::init(); - // TODO json logging in the future? + + // TODO use tracing instead of log let logger_env = env_logger::Env::new().filter_or("RUST_LOG", "info"); env_logger::init_from_env(logger_env); @@ -97,18 +97,6 @@ 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() - .with_webpki_roots() - .https_only() - .enable_http1() - .enable_http2() - .build(); - 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 = { @@ -119,7 +107,7 @@ async fn main() { "/", env!("CARGO_PKG_VERSION") )); - // TODO add a root certificate if there's an environment variable pointing at it + // 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() @@ -155,14 +143,18 @@ async fn main() { let onboarding = warp::path("onboarding") .and(warp::path::end()) - .and(kittybox::frontend::onboarding(database.clone(), endpoints.clone(), http_client.clone())); + .and(kittybox::frontend::onboarding( + database.clone(), + endpoints.clone(), + http.clone() + )); let micropub = warp::path("micropub") .and(warp::path::end() .and(kittybox::micropub::micropub( database.clone(), token_endpoint.to_string(), - http_client.clone() + http.clone() )) .or(warp::get() .and(warp::path("client")) |