Include Static Resources for Rocket Framework

CI

This is a crate which provides macros static_resources_initializer! and static_response_handler! to statically include files from your Rust project and make them be the HTTP response sources quickly.

Example

```rust

[macro_use]

extern crate rocket;

[macro_use]

extern crate rocketincludestatic_resources;

use rocket::State;

use rocketincludestatic_resources::{EtagIfNoneMatch, StaticContextManager, StaticResponse};

staticresponsehandler! { "/favicon.ico" => favicon => "favicon", "/favicon-16.png" => favicon_png => "favicon-png", }

[get("/")]

fn index( staticresources: &State, etagifnonematch: EtagIfNoneMatch, ) -> StaticResponse { staticresources.build(&etagifnonematch, "html-readme") }

[launch]

fn rocket() -> _ { rocket::build() .attach(staticresourcesinitializer!( "favicon" => "examples/front-end/images/favicon.ico", "favicon-png" => "examples/front-end/images/favicon-16.png", "html-readme" => ("examples", "front-end", "html", "README.html"), )) .mount("/", routes![favicon, favicon_png]) .mount("/", routes![index]) } ```

See examples.

Crates.io

https://crates.io/crates/rocket-include-static-resources

Documentation

https://docs.rs/rocket-include-static-resources

License

MIT