#[macro_use] extern crate rocket; use dotenv::dotenv; use rocket_contrib::templates::Template; use serde::Serialize; mod slack; mod weather; #[derive(Serialize)] struct Context {} #[get("/weather/")] async fn get_weather(loc: String) -> Result { let sum = weather::get_summary(&loc).await?; Ok(format!("The weather in {} is: {:?}", loc, sum)) } #[get("/slack/")] async fn set_status(msg: String) -> Result { slack::set_status(&msg).await?; Ok("woohoo".to_owned()) } #[get("/")] async fn index() -> Template { let ctx = Context {}; Template::render("index", &ctx) } #[rocket::launch] fn rocket() -> rocket::Rocket { dotenv().ok(); rocket::ignite() .attach(Template::fairing()) .mount("/", routes![index, get_weather, set_status]) }