2023-05-24 15:36:38 +02:00
|
|
|
use rocket::{get, routes, Route, State};
|
|
|
|
use sqlx::SqlitePool;
|
|
|
|
|
2023-05-30 14:12:08 +02:00
|
|
|
use crate::{model::log::Log, rest::Config};
|
2023-04-04 10:44:14 +02:00
|
|
|
|
2023-04-04 12:19:56 +02:00
|
|
|
pub mod planned_event;
|
2023-04-04 10:44:14 +02:00
|
|
|
pub mod user;
|
|
|
|
|
2023-05-24 15:36:38 +02:00
|
|
|
#[get("/rss?<key>")]
|
2023-05-30 14:12:08 +02:00
|
|
|
async fn rss(db: &State<SqlitePool>, key: Option<&str>, config: &State<Config>) -> String {
|
2023-05-24 15:36:38 +02:00
|
|
|
match key {
|
2023-05-30 14:12:08 +02:00
|
|
|
Some(key) if key.eq(&config.rss_key) => Log::generate_feed(db).await,
|
2023-05-24 15:36:38 +02:00
|
|
|
_ => "Not allowed".to_string(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-04 10:44:14 +02:00
|
|
|
pub fn routes() -> Vec<Route> {
|
|
|
|
let mut ret = Vec::new();
|
|
|
|
ret.append(&mut user::routes());
|
2023-04-04 12:19:56 +02:00
|
|
|
ret.append(&mut planned_event::routes());
|
2023-05-24 15:36:38 +02:00
|
|
|
ret.append(&mut routes![rss]);
|
2023-04-04 10:44:14 +02:00
|
|
|
ret
|
|
|
|
}
|