This crate provides a static file server for Rocket backed by the rust-embed
crate. This allows users to ship their frontend with their webserver.
!!! This crate is currently very young and naively written. Please check the code thoroughly before even thinking about using it in anything important !!!
Since the crate is currently not hosted on crates.io, you need to add it to your project using git dependencies:
#Cargo.toml
#...
[dependencies]
rust-embed-rocket = {git = "https://github.com/peacememories/rust-embed-rocket"}
#...
Just create a RustEmbed
structure as described in their readme and use it to create an Asset
struct:
use rocket;
use rust_embed::RustEmbed;
use rust_embed_rocket::Server;
#[derive(RustEmbed)]
#[folder = "examples/public/"]
struct Asset;
fn main() {
rocket::ignite().mount("/", Server::from(Asset)).launch();
}
The Rocket rank (see here) can be set by changing the rank
option supplied to from_config
.
Default: 0
It is common to want a url like /foo
to serve the file /foo/index.html
. This can be done by enabling the boolean serve_index
in the config.
Default: false
Feedback and Contributions are welcome, either through GitHubs issue and pr tracker or on Riot/IRC under the handle @peacememories
Please respect the Rust Code of Conduct