rustical_dav_push/
endpoints.rs1use axum::{
2 Router,
3 extract::{Path, State},
4 response::{IntoResponse, Response},
5 routing::delete,
6};
7use http::StatusCode;
8use rustical_store::SubscriptionStore;
9use std::sync::Arc;
10
11async fn handle_delete<S: SubscriptionStore>(
12 State(store): State<Arc<S>>,
13 Path(id): Path<String>,
14) -> Result<Response, rustical_store::Error> {
15 store.delete_subscription(&id).await?;
16 Ok((StatusCode::NO_CONTENT, "Unregistered").into_response())
17}
18
19pub fn subscription_service<S: SubscriptionStore>(sub_store: Arc<S>) -> Router {
20 Router::new()
21 .route("/push_subscription/{id}", delete(handle_delete::<S>))
22 .with_state(sub_store)
23}