Include Static Resources for Rocket Framework

Build Status

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

```rust

![feature(procmacrohygiene, decl_macro)]

[macro_use]

extern crate rocket;

[macro_use]

extern crate rocketincludestatic_resources;

use rocketincludestatic_resources::{EtagIfNoneMatch, StaticResponse};

[get("/favicon.ico")]

fn favicon(etagifnonematch: EtagIfNoneMatch) -> StaticResponse { staticresponse!(etagifnone_match, "favicon") }

[get("/favicon-16.png")]

fn faviconpng() -> StaticResponse { staticresponse!("favicon-png") }

[get("/")]

fn index(etagifnonematch: EtagIfNoneMatch) -> StaticResponse { staticresponse!(etagifnone_match, "html-readme") }

fn main() { rocket::ignite() .attach(StaticResponse::fairing(|resources| { staticresourcesinitialize!( resources,

            "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])
    .launch();

} ```

See examples.

Crates.io

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

Documentation

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

License

MIT