mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
log the index created route
This commit is contained in:
parent
d72c887422
commit
6b8e5a4c92
@ -4,7 +4,9 @@ use log::debug;
|
|||||||
use meilisearch_lib::index_controller::IndexSettings;
|
use meilisearch_lib::index_controller::IndexSettings;
|
||||||
use meilisearch_lib::MeiliSearch;
|
use meilisearch_lib::MeiliSearch;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
|
use crate::analytics::Analytics;
|
||||||
use crate::error::ResponseError;
|
use crate::error::ResponseError;
|
||||||
use crate::extractors::authentication::{policies::*, GuardedData};
|
use crate::extractors::authentication::{policies::*, GuardedData};
|
||||||
use crate::routes::IndexParam;
|
use crate::routes::IndexParam;
|
||||||
@ -54,8 +56,14 @@ pub struct IndexCreateRequest {
|
|||||||
pub async fn create_index(
|
pub async fn create_index(
|
||||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||||
body: web::Json<IndexCreateRequest>,
|
body: web::Json<IndexCreateRequest>,
|
||||||
|
analytics: web::Data<&'static dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let body = body.into_inner();
|
let body = body.into_inner();
|
||||||
|
|
||||||
|
analytics.publish(
|
||||||
|
"Index Created".to_string(),
|
||||||
|
json!({ "with_primary_key": body.primary_key}),
|
||||||
|
);
|
||||||
let meta = meilisearch.create_index(body.uid, body.primary_key).await?;
|
let meta = meilisearch.create_index(body.uid, body.primary_key).await?;
|
||||||
Ok(HttpResponse::Created().json(meta))
|
Ok(HttpResponse::Created().json(meta))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user