diff options
Diffstat (limited to 'src/frontend/mod.rs')
-rw-r--r-- | src/frontend/mod.rs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 8155b2c..2cef026 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -705,7 +705,12 @@ struct OnboardingData { pub async fn onboarding_receiver<S: Storage>(mut req: Request<ApplicationState<S>>) -> Result { use serde_json::json; - <AsMut<tide::http::Request>>::as_mut(&mut req).url_mut().set_scheme("https"); + // This cannot error out as the URL must be valid. Or there is something horribly wrong + // and we shouldn't serve this request anyway. + <dyn AsMut<tide::http::Request>>::as_mut(&mut req) + .url_mut() + .set_scheme("https") + .unwrap(); let body = req.body_json::<OnboardingData>().await?; let backend = &req.state().storage; @@ -784,7 +789,12 @@ pub async fn coffee<S: Storage>(_: Request<ApplicationState<S>>) -> Result { } pub async fn mainpage<S: Storage>(mut req: Request<ApplicationState<S>>) -> Result { - <AsMut<tide::http::Request>>::as_mut(&mut req).url_mut().set_scheme("https"); + // This cannot error out as the URL must be valid. Or there is something horribly wrong + // and we shouldn't serve this request anyway. + <dyn AsMut<tide::http::Request>>::as_mut(&mut req) + .url_mut() + .set_scheme("https") + .unwrap(); let backend = &req.state().storage; let query = req.query::<QueryParams>()?; let authorization_endpoint = req.state().authorization_endpoint.to_string(); @@ -863,7 +873,12 @@ pub async fn render_post<S: Storage>(mut req: Request<ApplicationState<S>>) -> R let token_endpoint = req.state().token_endpoint.to_string(); let user: Option<String> = None; - <AsMut<tide::http::Request>>::as_mut(&mut req).url_mut().set_scheme("https"); + // This cannot error out as the URL must be valid. Or there is something horribly wrong + // and we shouldn't serve this request anyway. + <dyn AsMut<tide::http::Request>>::as_mut(&mut req) + .url_mut() + .set_scheme("https") + .unwrap(); #[cfg(any(not(debug_assertions), test))] let url = req.url(); #[cfg(all(debug_assertions, not(test)))] @@ -875,8 +890,8 @@ pub async fn render_post<S: Storage>(mut req: Request<ApplicationState<S>>) -> R let mut entry_url = req.url().clone(); entry_url.set_query(None); - let post = - get_post_from_database(&req.state().storage, entry_url.as_str(), query.after, &user).await?; + let post = get_post_from_database(&req.state().storage, entry_url.as_str(), query.after, &user) + .await?; let template: String = match post["type"][0] .as_str() |