use rocket::{get, routes, Route, State}; use sqlx::SqlitePool; use crate::model::planned_event::PlannedEvent; #[get("/")] async fn index(db: &State) -> String { let mut res = String::from( r#"BEGIN:VCALENDAR VERSION:2.0 PRODID:-//rudernlinz.at//Trips//DE"#, ); let events = PlannedEvent::all(db).await; for event in events { res.push_str("\nBEGIN:VEVENT"); res.push_str(&format!("\nUID:{}@rudernlinz.at", event.id)); res.push_str(&format!( "\nDTSTART:{}T{}00Z", event.day.replace("-", ""), event.planned_starting_time.replace(":", "") )); res.push_str(&format!("\nSUMMARY:{}", event.name)); res.push_str("\nEND:VEVENT"); } res.push_str("\nEND:VCALENDAR"); res } pub fn routes() -> Vec { routes![index] }