remove api crate

This commit is contained in:
Lennart
2024-03-12 13:54:09 +01:00
parent 128e8c5531
commit 423d3c9d13
5 changed files with 13 additions and 54 deletions

View File

@@ -1,12 +0,0 @@
[package]
name = "rustical_api"
version = "0.1.0"
edition = "2021"
[dependencies]
actix-web = "4.4"
anyhow = { version = "1.0", features = ["backtrace"] }
rustical_store = { path = "../store/" }
serde = "1.0"
serde_json = "1.0"
tokio = { version = "1.32", features = ["sync"] }

View File

@@ -1,26 +0,0 @@
use actix_web::{
http::Method,
web::{self, Data, Path},
Responder,
};
use rustical_store::calendar::CalendarStore;
use tokio::sync::RwLock;
pub fn configure_api<C: CalendarStore + ?Sized>(
cfg: &mut web::ServiceConfig,
store: Data<RwLock<C>>,
) {
cfg.app_data(store).route(
"/{cid}/events",
web::method(Method::GET).to(get_events::<C>),
);
}
pub async fn get_events<C: CalendarStore + ?Sized>(
store: Data<RwLock<C>>,
path: Path<String>,
) -> impl Responder {
let cid = path.into_inner();
let events = store.read().await.get_events(&cid).await.unwrap();
serde_json::to_string_pretty(&events)
}