1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-07-31 13:07:46 +00:00

Rename name to path in asset serving

This commit is contained in:
RGBCube 2023-12-31 13:52:31 +03:00
parent c3d45b6ba4
commit 820b48fa7a
No known key found for this signature in database

View file

@ -59,14 +59,14 @@ static ASSETS: LazyLock<HashMap<String, Bytes>> = LazyLock::new(|| {
assets
});
#[get("/assets/{name}")]
pub async fn handler(name: web::Path<String>) -> HttpResponse {
let name = name.into_inner();
#[get("/assets/{path}")]
pub async fn handler(path: web::Path<String>) -> HttpResponse {
let path = path.into_inner();
if let Some(body) = ASSETS.get(&name) {
if let Some(body) = ASSETS.get(&path) {
HttpResponse::Ok()
.content_type(
mime_guess::from_path(&name)
mime_guess::from_path(&path)
.first_or_octet_stream()
.essence_str(),
)