is possible to server from a file imported using include_bytes! macro? #1929
-
Greetings Rocket Experts, I would like to package my Rocket application as a stand alone binary. So, I would like to use Is there a way I can still serve the file using Am I missing a possible solution? Or does this feature just not exist in Rocket? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Not only is it possible, it's intended to be pretty straightforward to do things like this! For example: use rocket::http::ContentType;
#[get("/example.png")]
fn image() -> (ContentType, &'static [u8]) {
(ContentType::PNG, include_bytes!("/tmp/example.png"))
} |
Beta Was this translation helpful? Give feedback.
NamedFile
is used specifically to serve files from disk; there's no need to use it at the same time asinclude_bytes!
.Not only is it possible, it's intended to be pretty straightforward to do things like this! For example: