Skip to main content

max / makenotwork

1.1 KB · 31 lines History Blame Raw
1 //! HTML page routes, split by domain.
2
3 mod blog;
4 pub(crate) mod dashboard;
5 mod email_actions;
6 mod feeds;
7 pub(crate) mod public;
8 mod sandbox;
9
10 use crate::{AppState, csrf::CsrfRouter};
11 use axum::Router;
12
13 /// Compose the page tree from posture-declared sub-groups and `finalize()` once.
14 ///
15 /// Every sub-router is a `CsrfRouter`, and `CsrfRouter::merge` only accepts
16 /// another `CsrfRouter`, so a bare `axum::Router` (which can carry an
17 /// undeclared mutation route) is a *type error* here, not a silent CSRF bypass.
18 /// A group merged as a bare `Router` (`email_actions`, `sandbox`, `feeds`,
19 /// `blog`) skips the envelope, and its mutation routes go unprotected.
20 /// `finalize()` drops the wrapper exactly once, here.
21 pub fn page_routes(limits: crate::constants::RateLimits) -> Router<AppState> {
22 CsrfRouter::new()
23 .merge(public::public_routes(limits))
24 .merge(sandbox::sandbox_routes(limits))
25 .merge(dashboard::dashboard_routes())
26 .merge(email_actions::email_action_routes(limits))
27 .merge(feeds::feed_routes())
28 .merge(blog::blog_routes())
29 .finalize()
30 }
31