Skip to content

A rocket handler using a filesystem embedded into your executable

Notifications You must be signed in to change notification settings

peacememories/rust-embed-rocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Embed Rocket

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 !!!

Install

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"}
#...

Example

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();
}

Configuration Options

Rank

The Rocket rank (see here) can be set by changing the rank option supplied to from_config.

Default: 0

Serve Index

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 & Contributions

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

About

A rocket handler using a filesystem embedded into your executable

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages