#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_failure;
use rocket_failure::errors::*;
use std::fs;
#[get("/<file>")]
fn index(file: String) -> ApiResult<Vec<u8>> {
if !file.chars().all(|c| char::is_alphanumeric(c) || c == '-' || c == '.') {
bad_request!("file contains forbidden characters")
}
let content = fs::read(&file)
.not_found()?;
Ok(content)
}
fn main() {
rocket::ignite().mount("/", routes![index]).launch();
}