feat(server): register upload route and static file serving

This commit is contained in:
xfy 2026-06-05 15:14:10 +08:00
parent 371ebcf8f9
commit 76797f1bc3
2 changed files with 3 additions and 1 deletions

View File

@ -21,7 +21,7 @@ tower-http = { version = "0.6", features = ["trace", "fs"], optional = true }
rand = { version = "0.8", features = ["getrandom"] } rand = { version = "0.8", features = ["getrandom"] }
getrandom = { version = "0.2", features = ["js"] } getrandom = { version = "0.2", features = ["js"] }
http = "1" http = "1"
axum = { version = "0.7", optional = true, features = ["multipart"] } axum = { version = "0.8", optional = true, features = ["multipart"] }
serde_json = "1.0" serde_json = "1.0"
ammonia = { version = "4", optional = true } ammonia = { version = "4", optional = true }
syntect = { version = "5", default-features = false, features = ["default-syntaxes", "default-themes", "default-fancy", "html", "parsing", "dump-load", "yaml-load"], optional = true } syntect = { version = "5", default-features = false, features = ["default-syntaxes", "default-themes", "default-fancy", "html", "parsing", "dump-load", "yaml-load"], optional = true }

View File

@ -45,6 +45,8 @@ fn main() {
.invalidate_after(std::time::Duration::from_secs(300)), .invalidate_after(std::time::Duration::from_secs(300)),
); );
let router = axum::Router::new() let router = axum::Router::new()
.route("/api/upload", axum::routing::post(crate::api::upload::upload_image))
.nest_service("/uploads", tower_http::services::ServeDir::new("uploads"))
.serve_dioxus_application(config, router::AppRouter) .serve_dioxus_application(config, router::AppRouter)
.layer( .layer(
TraceLayer::new_for_http() TraceLayer::new_for_http()