mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 19:22:26 +00:00
24 lines
665 B
Rust
24 lines
665 B
Rust
use axum::{
|
|
Router,
|
|
extract::{Path, State},
|
|
response::{IntoResponse, Response},
|
|
routing::delete,
|
|
};
|
|
use http::StatusCode;
|
|
use rustical_store::SubscriptionStore;
|
|
use std::sync::Arc;
|
|
|
|
async fn handle_delete<S: SubscriptionStore>(
|
|
State(store): State<Arc<S>>,
|
|
Path(id): Path<String>,
|
|
) -> Result<Response, rustical_store::Error> {
|
|
store.delete_subscription(&id).await?;
|
|
Ok((StatusCode::NO_CONTENT, "Unregistered").into_response())
|
|
}
|
|
|
|
pub fn subscription_service<S: SubscriptionStore>(sub_store: Arc<S>) -> Router {
|
|
Router::new()
|
|
.route("/push_subscription/{id}", delete(handle_delete::<S>))
|
|
.with_state(sub_store)
|
|
}
|