about summary refs log tree commit diff
path: root/src/frontend/mod.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-08-01 20:01:12 +0300
committerVika <vika@fireburn.ru>2024-08-01 20:40:30 +0300
commit4ca0c24b1989fcd12c453d428af70f58456f7651 (patch)
tree19f480107cc6491b832a7a2d7198cee48f205b85 /src/frontend/mod.rs
parent7e8e688e2e58f9c944b941e768ab7b034a348a1f (diff)
Migrate from axum::Extension to axum::extract::State
This somehow allowed me to shrink the construction phase of Kittybox
by a huge amount of code.
Diffstat (limited to 'src/frontend/mod.rs')
-rw-r--r--src/frontend/mod.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs
index 0292171..42e8754 100644
--- a/src/frontend/mod.rs
+++ b/src/frontend/mod.rs
@@ -1,9 +1,8 @@
 use crate::database::{Storage, StorageError};
 use axum::{
-    extract::{Host, Path, Query},
+    extract::{Host, Query, State},
     http::{StatusCode, Uri},
     response::IntoResponse,
-    Extension,
 };
 use futures_util::FutureExt;
 use serde::Deserialize;
@@ -239,7 +238,7 @@ async fn get_post_from_database<S: Storage>(
 pub async fn homepage<D: Storage>(
     Host(host): Host,
     Query(query): Query<QueryParams>,
-    Extension(db): Extension<D>,
+    State(db): State<D>,
 ) -> impl IntoResponse {
     let user = None; // TODO authentication
     // This is stupid, but there is no other way.
@@ -333,7 +332,7 @@ pub async fn homepage<D: Storage>(
 
 #[tracing::instrument(skip(db))]
 pub async fn catchall<D: Storage>(
-    Extension(db): Extension<D>,
+    State(db): State<D>,
     Host(host): Host,
     Query(query): Query<QueryParams>,
     uri: Uri,