mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-05 20:48:58 +01:00
36cb09eb25
Move `meilisearch_error` to `meilisearch_types::error` Move `meilisearch_lib::index_resolver::IndexUid` to `meilisearch_types::index_uid` Add a new `InvalidIndexUid` error in `meilisearch_types::index_uid`
28 lines
950 B
Rust
28 lines
950 B
Rust
use actix_web::{web, HttpRequest, HttpResponse};
|
|
use log::debug;
|
|
use meilisearch_lib::MeiliSearch;
|
|
use meilisearch_types::error::ResponseError;
|
|
use serde_json::json;
|
|
|
|
use crate::analytics::Analytics;
|
|
use crate::extractors::authentication::{policies::*, GuardedData};
|
|
use crate::extractors::sequential_extractor::SeqHandler;
|
|
use crate::task::SummarizedTaskView;
|
|
|
|
pub fn configure(cfg: &mut web::ServiceConfig) {
|
|
cfg.service(web::resource("").route(web::post().to(SeqHandler(create_dump))));
|
|
}
|
|
|
|
pub async fn create_dump(
|
|
meilisearch: GuardedData<ActionPolicy<{ actions::DUMPS_CREATE }>, MeiliSearch>,
|
|
req: HttpRequest,
|
|
analytics: web::Data<dyn Analytics>,
|
|
) -> Result<HttpResponse, ResponseError> {
|
|
analytics.publish("Dump Created".to_string(), json!({}), Some(&req));
|
|
|
|
let res: SummarizedTaskView = meilisearch.register_dump_task().await?.into();
|
|
|
|
debug!("returns: {:?}", res);
|
|
Ok(HttpResponse::Accepted().json(res))
|
|
}
|