1
Fork 0
mirror of https://github.com/RGBCube/rgbcube.github.io synced 2025-05-14 05:54:58 +00:00

Add assets serving

This commit is contained in:
RGBCube 2023-12-20 22:45:22 +03:00
parent 45dfbddb3d
commit da93443b5c
No known key found for this signature in database
3 changed files with 54 additions and 0 deletions

51
Cargo.lock generated
View file

@ -347,6 +347,12 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "http-range-header"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe"
[[package]]
name = "httparse"
version = "1.8.0"
@ -505,6 +511,16 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "minify-js"
version = "0.5.6"
@ -824,6 +840,7 @@ dependencies = [
"maud",
"minify-js",
"tokio",
"tower-http",
]
[[package]]
@ -937,6 +954,31 @@ dependencies = [
"tracing",
]
[[package]]
name = "tower-http"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09e12e6351354851911bdf8c2b8f2ab15050c567d70a8b9a37ae7b8301a4080d"
dependencies = [
"bitflags 2.4.1",
"bytes",
"futures-util",
"http",
"http-body",
"http-body-util",
"http-range-header",
"httpdate",
"mime",
"mime_guess",
"percent-encoding",
"pin-project-lite",
"tokio",
"tokio-util",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tower-layer"
version = "0.3.2"
@ -969,6 +1011,15 @@ dependencies = [
"once_cell",
]
[[package]]
name = "unicase"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"

View file

@ -17,6 +17,7 @@ log = "0.4.20"
maud = { git = "https://github.com/vidhanio/maud", branch = "patch-1", features = [ "axum" ] }
minify-js = "0.5.6"
tokio = { version = "1.35.1", features = [ "full" ] }
tower-http = { version = "0.5.0", features = [ "fs", "trace" ] }
[build]
incremental = true

View file

@ -13,6 +13,7 @@ use constants::*;
use env_logger::Target;
use log::LevelFilter;
use tokio::net::TcpListener;
use tower_http::services::ServeDir;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
@ -22,6 +23,7 @@ async fn main() -> anyhow::Result<()> {
.init();
let app = Router::new()
.nest_service("/assets", ServeDir::new("assets")) // TODO: Embed it all.
.route("/", get(pages::index))
.fallback(pages::_404);