diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2025-06-17 02:03:28 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2025-06-18 18:31:40 -0400 |
| commit | 5ed96f8e8b9d9f19ee249f5c73a5a21ef6bca09f (patch) | |
| tree | 75aa0287535506aa88f5f6d5b70ad5f99373320e /src/ui | |
| parent | 23c2f6fbc07f25a11826892d783bddcc93550d25 (diff) | |
Reorganize and consolidate HTTP routes.
HTTP routes are now defined in a single, unified module, pulling them out of the topical modules they were formerly part of.
This is intended to improve the navigability of the codebase. Previously, finding the handler corresponding to a specific endpoint required prior familiarity, though in practice you could usually guess from topic area. Now, all routes are defined in `crate::routes`.
Other than changing visibility, I've avoided making changes to the handlers at the ends of those routes.
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/mod.rs | 4 | ||||
| -rw-r--r-- | src/ui/routes/mod.rs | 35 |
2 files changed, 8 insertions, 31 deletions
diff --git a/src/ui/mod.rs b/src/ui/mod.rs index e834bba..eeaf27a 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,6 +1,4 @@ mod assets; mod error; mod mime; -mod routes; - -pub use self::routes::router; +pub mod routes; diff --git a/src/ui/routes/mod.rs b/src/ui/routes/mod.rs index dc94773..2390802 100644 --- a/src/ui/routes/mod.rs +++ b/src/ui/routes/mod.rs @@ -1,28 +1,7 @@ -use axum::{Router, response::Redirect, routing::get}; - -use crate::app::App; - -mod ch; -mod get; -mod invite; -mod login; -mod me; -mod path; -mod setup; - -pub fn router(app: &App) -> Router<App> { - [ - Router::new() - .route("/{*path}", get(path::get::handler)) - .route("/setup", get(setup::get::handler)), - Router::new() - .route("/", get(get::handler)) - .route("/me", get(me::get::handler)) - .route("/login", get(login::get::handler)) - .route("/ch/{channel}", get(ch::channel::get::handler)) - .route("/invite/{invite}", get(invite::invite::get::handler)) - .route_layer(crate::setup::Required(app.clone()).with_fallback(Redirect::to("/setup"))), - ] - .into_iter() - .fold(Router::default(), Router::merge) -} +pub mod ch; +pub mod get; +pub mod invite; +pub mod login; +pub mod me; +pub mod path; +pub mod setup; |
