Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sovereign-intelligence/blob/main/docs/archive/drakestapleton.com-old/crates/site-server/src/routes/pages.rs # sovereign-intelligence Front door to Drake Stapleton's sovereign stack. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `sovereign-intelligence / docs / archive / drakestapleton.com-old / crates / site-server / src / routes / pages.rs` 37 lines ยท 1345 bytes Raw Blame History 1 use axum::{ 2 body::Bytes, 3 extract::{OriginalUri, State}, 4 http::{header, HeaderMap, HeaderValue, StatusCode}, 5 response::{IntoResponse, Response}, 6 }; 7 use crate::state::AppState; 8 9 pub async fn serve_page( 10 State(state): State, 11 OriginalUri(uri): OriginalUri, 12 ) -> Response { 13 let path = uri.path(); 14 15 // Normalize trailing slash (except for root "/") 16 let normalized = if path.len() > 1 && path.ends_with('/') { 17 path.trim_end_matches('/') 18 } else { 19 path 20 }; 21 22 if let Some(content) = state.routes.get(normalized) { 23 let mut headers = HeaderMap::new(); 24 headers.insert(header::CONTENT_TYPE, HeaderValue::from_static("text/html; charset=utf-8")); 25 headers.insert(header::CACHE_CONTROL, HeaderValue::from_static("public, max-age=300, stale-while-revalidate=86400")); 26 (StatusCode::OK, headers, content.clone()).into_response() 27 } else { 28 let not_found_bytes = state 29 .routes 30 .get("/404") 31 .cloned() 32 .unwrap_or_else(|| Bytes::from_static(b"

404 - Page Not Found

")); 33 let mut headers = HeaderMap::new(); 34 headers.insert(header::CONTENT_TYPE, HeaderValue::from_static("text/html; charset=utf-8")); 35 (StatusCode::NOT_FOUND, headers, not_found_bytes).into_response() 36 } 37 }