Embed UI templates and static assets into binary; simplify deployment to single file; Update script files

This commit is contained in:
2026-04-27 13:35:50 +08:00
parent 02fa9d612c
commit 05a30d2227
11 changed files with 435 additions and 529 deletions

View File

@@ -1,4 +1,5 @@
pub mod config;
pub mod embedded;
pub mod handlers;
pub mod middleware;
pub mod services;
@@ -321,14 +322,12 @@ pub fn create_ui_router(state: state::AppState) -> Router {
secure: false,
};
let static_service = tower::ServiceBuilder::new()
.layer(tower_http::set_header::SetResponseHeaderLayer::overriding(
axum::http::header::CACHE_CONTROL,
axum::http::HeaderValue::from_static("no-cache"),
))
.service(tower_http::services::ServeDir::new(
&state.config.static_dir,
));
let static_router = Router::new()
.route(
"/static/{*path}",
axum::routing::get(handlers::static_assets::serve),
)
.with_state(state.clone());
protected
.merge(public)
@@ -346,7 +345,7 @@ pub fn create_ui_router(state: state::AppState) -> Router {
middleware::ui_metrics_layer,
))
.with_state(state)
.nest_service("/static", static_service)
.merge(static_router)
.layer(axum::middleware::from_fn(middleware::server_header))
.layer(tower_http::compression::CompressionLayer::new())
}