diff --git a/meilisearch/src/routes/logs.rs b/meilisearch/src/routes/logs.rs index b40a34b91..ca1ca2d2f 100644 --- a/meilisearch/src/routes/logs.rs +++ b/meilisearch/src/routes/logs.rs @@ -13,8 +13,6 @@ use meilisearch_types::deserr::DeserrJsonError; use meilisearch_types::error::deserr_codes::*; use meilisearch_types::error::ResponseError; use tokio::sync::mpsc::{self, UnboundedSender}; -use tracing::instrument::WithSubscriber; -use tracing_subscriber::filter::Targets; use tracing_subscriber::Layer; use crate::error::MeilisearchHttpError; @@ -24,7 +22,11 @@ use crate::extractors::sequential_extractor::SeqHandler; use crate::LogRouteHandle; pub fn configure(cfg: &mut web::ServiceConfig) { - cfg.service(web::resource("").route(web::post().to(SeqHandler(get_logs)))); + cfg.service( + web::resource("") + .route(web::post().to(SeqHandler(get_logs))) + .route(web::delete().to(SeqHandler(cancel_logs))), + ); } #[derive(Debug, Default, Clone, Copy, Deserr)] @@ -189,3 +191,15 @@ pub async fn get_logs( Err(MeilisearchHttpError::AlreadyUsedLogRoute.into()) } } + +pub async fn cancel_logs( + _auth_controller: GuardedData, Data>, + logs: Data, + _req: HttpRequest, +) -> Result { + if let Err(e) = logs.modify(|layer| *layer.inner_mut() = None) { + tracing::error!("Could not free the logs route: {e}"); + } + + Ok(HttpResponse::NoContent().finish()) +}