Closed LuckyTurtleDev closed 2 years ago
Description Result<RawJavaScript<String>, std::io::Error> does return text/html instead of application/javascript. Similarly behavior for NamedFile does also return text/html.
Result<RawJavaScript<String>, std::io::Error>
text/html
application/javascript
NamedFile
To Reproduce
#[get("/widget-api.js")] async fn widget_api_js() -> std::io::Result<NamedFile> { NamedFile::open("widget-api.js").await } #[get("/index.js")] async fn index_js() -> Result<RawJavaScript<String>, std::io::Error> { match read_to_string("index.js").await { Err(error) => Err(error), Ok(value) => Ok(RawJavaScript(value)) } } #[launch] async fn rocket() -> _ { let shield = Shield::default().disable::<rocket::shield::Frame>(); rocket::build().mount("/", routes![index_js,widget_api_js]).attach(Template::fairing()).attach(shield) }
Expected Behavior
Return application/javascript for booth routs
Environment:
██████████████████ ████████ ***@*** ██████████████████ ████████ ------------ ██████████████████ ████████ OS: Manjaro Linux x86_64 ██████████████████ ████████ Host: 82N7 Yoga 7 14ACN6 ████████ ████████ Kernel: 5.19.0-2-MANJARO ████████ ████████ ████████ Uptime: 1 hour, 36 mins ████████ ████████ ████████ Packages: 1633 (pacman) ████████ ████████ ████████ Shell: bash 5.1.16 ████████ ████████ ████████ Resolution: 1920x1200 ████████ ████████ ████████ DE: Plasma 5.24.6 ████████ ████████ ████████ WM: kwin ████████ ████████ ████████ Theme: [Plasma], Adapta-Nokto-Eta-Maia [GTK3] ████████ ████████ ████████ Icons: Papirus-Dark-Maia [Plasma], Papirus-Dark-Maia [GTK2/3] ████████ ████████ ████████ Terminal: alacritty CPU: AMD Ryzen 7 5800U with Radeon Graphics (16) @ 1.900GHz GPU: AMD ATI 03:00.0 Cezanne Memory: 6847MiB / 13832MiB
[[package]] name = "rocket" version = "0.5.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ead083fce4a405feb349cf09abdf64471c6077f14e0ce59364aa90d4b99317" dependencies = [ "async-stream", "async-trait", "atomic", "atty", "binascii", "bytes", "either", "figment", "futures", "indexmap", "log", "memchr", "multer", "num_cpus", "parking_lot", "pin-project-lite", "rand", "ref-cast", "rocket_codegen", "rocket_http", "serde", "state", "tempfile", "time", "tokio", "tokio-stream", "tokio-util", "ubyte", "version_check", "yansi", ]
same behavior for RawJavaScript<String> (without result)
RawJavaScript<String>
Sorry I have use wrong url and rocket has return the default error message.
Description
Result<RawJavaScript<String>, std::io::Error>
does returntext/html
instead ofapplication/javascript
. Similarly behavior forNamedFile
does also returntext/html
.To Reproduce
Expected Behavior
Return
application/javascript
for booth routsEnvironment: