summaryrefslogtreecommitdiff
path: root/src/handlers/mod.rs
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2024-10-28 19:28:41 +0100
committerWriterV2 <primary-v2@protonmail.com>2024-10-28 19:28:41 +0100
commit977c93ef0568aa488c226915d14e6f164519fd98 (patch)
tree276dd1237f51d1b7fab526b3f12a9b798d0f5209 /src/handlers/mod.rs
parent04e19765aca471fd85199714699aaf827d04608d (diff)
Feat: Add admin API route to add story
Diffstat (limited to 'src/handlers/mod.rs')
-rw-r--r--src/handlers/mod.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index d69f590..d346512 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -1,21 +1,29 @@
use axum::extract::DefaultBodyLimit;
use axum::middleware::{self};
-use axum::routing::get;
+use axum::routing::{get, post};
use axum::Router;
use sqlx::SqlitePool;
+use tower_http::add_extension::AddExtensionLayer;
use tower_http::services::ServeDir;
-use admin::{admin_handler, admin_middleware};
+use admin::{admin_healthcheck, admin_middleware, upload_story};
use frontend::home;
mod admin;
mod frontend;
+#[derive(Debug, Clone)]
+struct ApiContext {
+ pool: SqlitePool,
+}
+
pub async fn router(pool: SqlitePool) -> Router {
Router::new()
- .route("/admin", get(admin_handler))
+ .route("/admin/story", post(upload_story))
+ .route("/admin", get(admin_healthcheck))
.layer(middleware::from_fn(admin_middleware))
.route("/", get(home))
.nest_service("/static", ServeDir::new("src/static"))
- .layer(DefaultBodyLimit::max(10000))
+ .layer(DefaultBodyLimit::max(1074000000))
+ .layer(AddExtensionLayer::new(ApiContext { pool }))
}