I am trying to send a file that I included in binary with include_bytes!in an Iron application. I want to get one file for my application, and it needs only a few HTML, CSS and JS files. Here is a small test setup in which I play:
extern crate iron;
use iron::prelude::*;
use iron::status;
use iron::mime::Mime;
fn main() {
let index_html = include_bytes!("static/index.html");
println!("Hello, world!");
Iron::new(| _: &mut Request| {
let content_type = "text/html".parse::<Mime>().unwrap();
Ok(Response::with((content_type, status::Ok, index_html)))
}).http("localhost:8001").unwrap();
}
Of course, this does not work, because it index_htmlhas type&[u8; 78]
src/main.rs:16:12: 16:26 error: the trait `modifier::Modifier<iron::response::Response>` is not implemented for the type `&[u8; 78]` [E0277]
src/main.rs:16 Ok(Response::with((content_type, status::Ok, index_html)))
Since I'm completely new to Rust and Iron, I have no idea how to approach this. I tried to learn something from Iron documents, but I think my knowledge of Rust is not enough to really understand them, especially what should be in this trait modifier::Modifier.
? -, - Modifier?