Commit 445ad0fa89d7d58a6f0962fe1bb4c757f02f80d8
1 parent
88cfb041
Set content-type when sending javascript or wasm code
Showing
4 changed files
with
23 additions
and
1 deletions
... | ... | @@ -12,6 +12,8 @@ mod upload_worker; |
12 | 12 | use models::image::Image; |
13 | 13 | use routes::markdown::*; |
14 | 14 | use routes::other::*; |
15 | +use routes::ui::frontend_js; | |
16 | +use routes::ui::frontend_wasm; | |
15 | 17 | use routes::user::*; |
16 | 18 | use routes::upload::*; |
17 | 19 | use routes::image::*; |
... | ... | @@ -78,6 +80,12 @@ async fn main() -> std::io::Result<()> { |
78 | 80 | . route(web::put().to(update_user)) |
79 | 81 | ) |
80 | 82 | ) |
83 | + . service( web::scope("/ui") | |
84 | + . route( "/artshop_frontend.js" | |
85 | + , web::get().to(frontend_js) ) | |
86 | + . route( "/artshop_frontend_bg.wasm" | |
87 | + , web::get().to(frontend_wasm)) | |
88 | + ) | |
81 | 89 | . service( web::scope("") |
82 | 90 | . route("/", web::get().to(root)) |
83 | 91 | . route("/api.html", web::get().to(apidoc)) | ... | ... |
server/src/routes/ui.rs
0 → 100644
1 | +use actix_web::Error; | |
2 | +use actix_files::NamedFile; | |
3 | +use anyhow::Result; | |
4 | + | |
5 | +pub async fn frontend_js() -> Result<NamedFile, Error> { | |
6 | + Ok( NamedFile::open("static/ui/artshop_frontend.js")? | |
7 | + . set_content_type(mime::APPLICATION_JAVASCRIPT) ) | |
8 | +} | |
9 | + | |
10 | +pub async fn frontend_wasm() -> Result<NamedFile, Error> { | |
11 | + Ok( NamedFile::open("static/ui/artshop_frontend_bg.wasm")? | |
12 | + . set_content_type("application/wasm".parse::<mime::Mime>().unwrap()) ) | |
13 | +} | ... | ... |
Please
register
or
login
to post a comment