about summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs55
1 files changed, 2 insertions, 53 deletions
diff --git a/src/main.rs b/src/main.rs
index 90fa196..788e765 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,60 +1,9 @@
-use axum::extract::FromRef;
-use kittybox::{database::Storage, indieauth::backend::AuthBackend, media::storage::MediaStore, webmentions::Webmention};
+use kittybox::{database::Storage, indieauth::backend::AuthBackend, media::storage::MediaStore, webmentions::Webmention, compose_kittybox};
 use tokio::{sync::Mutex, task::JoinSet};
 use std::{env, time::Duration, sync::Arc};
 use tracing::error;
 
 
-async fn teapot_route() -> impl axum::response::IntoResponse {
-    use axum::http::{header, StatusCode};
-    (StatusCode::IM_A_TEAPOT, [(header::CONTENT_TYPE, "text/plain")], "Sorry, can't brew coffee yet!")
-}
-
-async fn health_check<D>(
-    axum::extract::State(data): axum::extract::State<D>,
-) -> impl axum::response::IntoResponse
-where
-    D: kittybox::database::Storage
-{
-    (axum::http::StatusCode::OK, std::borrow::Cow::Borrowed("OK"))
-}
-
-
-async fn compose_stateful_kittybox<St, A, S, M, Q>() -> axum::Router<St>
-where
-A: AuthBackend + 'static + FromRef<St>,
-S: Storage + 'static + FromRef<St>,
-M: MediaStore + 'static + FromRef<St>,
-Q: kittybox_util::queue::JobQueue<kittybox::webmentions::Webmention> + FromRef<St>,
-reqwest::Client: FromRef<St>,
-Arc<Mutex<JoinSet<()>>>: FromRef<St>,
-St: Clone + Send + Sync + 'static
-{
-    use axum::routing::get;
-    axum::Router::new()
-        .route("/", get(kittybox::frontend::homepage::<S>))
-        .fallback(get(kittybox::frontend::catchall::<S>))
-        .route("/.kittybox/micropub", kittybox::micropub::router::<A, S, St>())
-        .route("/.kittybox/onboarding", kittybox::frontend::onboarding::router::<St, S>())
-        .nest("/.kittybox/media", kittybox::media::router::<St, A, M>())
-        .merge(kittybox::indieauth::router::<St, A, S>())
-        .merge(kittybox::webmentions::router::<St, Q>())
-        .route("/.kittybox/health", get(health_check::<S>))
-        .route(
-            "/.kittybox/static/:path",
-            axum::routing::get(kittybox::frontend::statics)
-        )
-        .route("/.kittybox/coffee", get(teapot_route))
-        .nest("/.kittybox/micropub/client", kittybox::companion::router::<St>())
-        .layer(tower_http::trace::TraceLayer::new_for_http())
-        .layer(tower_http::catch_panic::CatchPanicLayer::new())
-        .layer(tower_http::sensitive_headers::SetSensitiveHeadersLayer::new([
-            axum::http::header::AUTHORIZATION,
-            axum::http::header::COOKIE,
-            axum::http::header::SET_COOKIE,
-        ]))
-}
-
 #[tokio::main]
 async fn main() {
     use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry};
@@ -221,7 +170,7 @@ async fn main() {
             };
 
             type St = kittybox::AppState<AuthBackend, Storage, MediaStore, JobQueue>;
-            let stateful_router = compose_stateful_kittybox::<St, AuthBackend, Storage, MediaStore, JobQueue>().await;
+            let stateful_router = compose_kittybox::<St, AuthBackend, Storage, MediaStore, JobQueue>().await;
             let task = kittybox::webmentions::supervised_webmentions_task::<St, Storage, JobQueue>(&state, cancellation_token.clone());
             let router = stateful_router.with_state(state);