Skip to main content

rustical_dav_push/
endpoints.rs

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