Include Static Resources for Rocket Framework
This is a crate which provides macros static_resources_initialize!
and static_response!
to statically include files from your Rust project and make them be the HTTP response sources quickly.
Example
extern crate rocket;
extern crate rocket_include_static_resources;
use StaticResponse;
static_resources_initialize!
is used in the fairing ofStaticResponse
to include static files into your executable binary file. You need to specify each file's name and its path. In order to reduce the compilation time and allow to hot-reload resources, files are compiled into your executable binary file together, only when you are using the release profile.static_response!
is used for retrieving the file you input through the macrostatic_resources_initialize!
as a Response instance into which three HTTP headers, Content-Type, Content-Length and Etag, will be automatically added.
See examples
.
Crates.io
https://crates.io/crates/rocket-include-static-resources
Documentation
https://docs.rs/rocket-include-static-resources