about summary refs log tree commit diff
path: root/src/frontend
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2021-07-29 18:14:30 +0300
committerVika <vika@fireburn.ru>2021-07-29 18:14:30 +0300
commit949a961c19ba994c3f0846e7b54d9a55a94d7b9a (patch)
treeb9d2031e1b08dcebf8f22c6051dea4da6e4f40ab /src/frontend
parentbd38e2f19b8c2c353ad759c1631b93b0f8eafbb0 (diff)
downloadkittybox-949a961c19ba994c3f0846e7b54d9a55a94d7b9a.tar.zst
Appease rustfmt, clippy and cargo check
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mod.rs25
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()