Content-Type
support)fn main() {
// Ensure AES_KEY is loaded when starting
let _ = key::get_key_from_env().unwrap();
let mut router = Router::new();
router.get("/", hello, "index");
router.get("/encode", test_encode, "test-encode");
router.post("/decode", test_decode, "test-decode");
Iron::new(router).http("0.0.0.0:8081").unwrap();
}
fn test_decode(r: &mut Request) -> IronResult<Response> {
let key_bytes = key::get_key_from_env().unwrap();
if let Ok(result) = decrypt_then_decode(&mut r.body, &key_bytes) {
Ok(Response::with((status::Ok, format!("{:?}", result))))
} else {
Ok(Response::with((status::BadRequest, "")))
}
}
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
fn main() {
rocket::ignite().mount("/", routes![index]).launch();
}
Responder
which asks for status in addition to content-type and body). Disappointing templating