use std::process::Command;

#[macro_use]
extern crate rocket;

#[get("/")]
fn index() -> Result<String, String> {
    String::try_from(
        Command::new("/usr/bin/fortune")
            .arg("fortunes")
            .output()
            .map_err(|e| e.to_string())?
            .stdout,
    )
    .map_err(|e| e.to_string())
}

#[launch]
fn rocket() -> _ {
    rocket::build().mount("/", routes![index])
}
