feat(maintenance): add a maintenance notification during backend migration
This commit is contained in:
@@ -687,13 +687,24 @@ pub fn create_api_routes(app_state: &Arc<AppState>) -> Router<Arc<AppState>> {
|
||||
// them on every overlapping request.
|
||||
router = router.route("/{*rest}", any(api_not_found));
|
||||
|
||||
// No per-router layers: the global `TraceLayer` + request-id stack in
|
||||
// `main.rs` wraps the whole app (this `/api` router is nested into it),
|
||||
// so a second `TraceLayer` here just double-wrapped every `/api`
|
||||
// request in a redundant span + response-future poll (benches/ROUND13.md
|
||||
// §H1). Compression is likewise the global layer's job — re-applying it
|
||||
// here (no predicate) would compress media downloads, burning CPU for
|
||||
// ~0 gain and stripping `Content-Length`.
|
||||
// Server-status header. Stamps `X-Server-Status` on every
|
||||
// response so the frontend's fetch wrapper can update a
|
||||
// reactive store — banner shows/hides without polling.
|
||||
// Sub-nanosecond on the hot path (single atomic load), a few
|
||||
// µs on the cold path (only during a running migration). See
|
||||
// `middleware::server_status`.
|
||||
let router = router.layer(axum::middleware::from_fn_with_state(
|
||||
app_state.clone(),
|
||||
crate::interfaces::middleware::server_status::server_status_middleware,
|
||||
));
|
||||
|
||||
// No per-router layers beyond that: the global `TraceLayer` + request-id
|
||||
// stack in `main.rs` wraps the whole app (this `/api` router is nested
|
||||
// into it), so a second `TraceLayer` here just double-wrapped every
|
||||
// `/api` request in a redundant span + response-future poll
|
||||
// (benches/ROUND13.md §H1). Compression is likewise the global layer's
|
||||
// job — re-applying it here (no predicate) would compress media
|
||||
// downloads, burning CPU for ~0 gain and stripping `Content-Length`.
|
||||
router
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user