page rewrite
Some checks failed
CI / Check typos (push) Failing after 8m53s
CI / Check links (push) Failing after 8m51s
CI / Clippy (push) Failing after 7m21s
CI / Build and test (push) Failing after 7m18s
CI / Build container (push) Has been skipped
CI / Deploy on waypoint (push) Has been skipped
Some checks failed
CI / Check typos (push) Failing after 8m53s
CI / Check links (push) Failing after 8m51s
CI / Clippy (push) Failing after 7m21s
CI / Build and test (push) Failing after 7m18s
CI / Build container (push) Has been skipped
CI / Deploy on waypoint (push) Has been skipped
This commit is contained in:
@@ -1,27 +1,39 @@
|
||||
use axum::Router;
|
||||
use macro_sass::sass;
|
||||
use page::{PageServer, asset::StaticAsset, redirect::Redirect};
|
||||
use std::sync::Arc;
|
||||
use page::{
|
||||
ServableRoute,
|
||||
servable::{Redirect, StaticAsset},
|
||||
};
|
||||
use toolbox::mime::MimeType;
|
||||
use tower_http::compression::{CompressionLayer, DefaultPredicate};
|
||||
|
||||
use crate::pages;
|
||||
|
||||
pub(super) fn router() -> Router<()> {
|
||||
build_server().into_router()
|
||||
let compression: CompressionLayer = CompressionLayer::new()
|
||||
.br(true)
|
||||
.deflate(true)
|
||||
.gzip(true)
|
||||
.zstd(true)
|
||||
.compress_when(DefaultPredicate::new());
|
||||
|
||||
build_server().into_router().layer(compression)
|
||||
}
|
||||
|
||||
fn build_server() -> Arc<PageServer> {
|
||||
let server = PageServer::new();
|
||||
|
||||
#[expect(clippy::unwrap_used)]
|
||||
server
|
||||
fn build_server() -> ServableRoute {
|
||||
ServableRoute::new()
|
||||
.with_404(pages::notfound())
|
||||
.add_page("/", pages::index())
|
||||
.add_page("/links", pages::links())
|
||||
.add_page("/whats-a-betalupi", pages::betalupi())
|
||||
.add_page("/handouts", pages::handouts())
|
||||
.add_page("/htwah", Redirect::new("/handouts").unwrap())
|
||||
.add_page("/htwah", {
|
||||
#[expect(clippy::unwrap_used)]
|
||||
Redirect::new("/handouts").unwrap()
|
||||
})
|
||||
.add_page("/htwah/typesetting", pages::htwah_typesetting())
|
||||
.add_page("/assets/htmx.js", page::HTMX_2_0_8)
|
||||
.add_page("/assets/htmx-json.js", page::EXT_JSON_1_19_12)
|
||||
//
|
||||
.add_page(
|
||||
"/assets/css/main.css",
|
||||
@@ -185,9 +197,7 @@ fn build_server() -> Arc<PageServer> {
|
||||
bytes: include_bytes!("../../assets/htwah/spacing-b.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
},
|
||||
);
|
||||
|
||||
server
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -197,7 +207,6 @@ fn server_builds_without_panic() {
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
// Needs tokio context
|
||||
let _server = build_server().into_router();
|
||||
let _server = build_server();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user