From dfce44fa3bb1a9dbfa1663e31b58b6443abc7d7e Mon Sep 17 00:00:00 2001 From: mpostma Date: Fri, 24 Sep 2021 12:03:16 +0200 Subject: [PATCH] rename data to meilisearch --- meilisearch-http/src/routes/dump.rs | 8 ++++---- meilisearch-http/src/routes/indexes/documents.rs | 16 ++++++++-------- meilisearch-http/src/routes/indexes/mod.rs | 12 ++++++------ meilisearch-http/src/routes/indexes/search.rs | 8 ++++---- meilisearch-http/src/routes/indexes/updates.rs | 8 ++++---- meilisearch-http/src/routes/mod.rs | 10 +++++----- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/meilisearch-http/src/routes/dump.rs b/meilisearch-http/src/routes/dump.rs index a598f875b..494e97516 100644 --- a/meilisearch-http/src/routes/dump.rs +++ b/meilisearch-http/src/routes/dump.rs @@ -11,8 +11,8 @@ pub fn configure(cfg: &mut web::ServiceConfig) { .service(web::resource("/{dump_uid}/status").route(web::get().to(get_dump_status))); } -pub async fn create_dump(data: GuardedData) -> Result { - let res = data.create_dump().await?; +pub async fn create_dump(meilisearch: GuardedData) -> Result { + let res = meilisearch.create_dump().await?; debug!("returns: {:?}", res); Ok(HttpResponse::Accepted().json(res)) @@ -30,10 +30,10 @@ struct DumpParam { } async fn get_dump_status( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, ) -> Result { - let res = data.dump_info(path.dump_uid.clone()).await?; + let res = meilisearch.dump_info(path.dump_uid.clone()).await?; debug!("returns: {:?}", res); Ok(HttpResponse::Ok().json(res)) diff --git a/meilisearch-http/src/routes/indexes/documents.rs b/meilisearch-http/src/routes/indexes/documents.rs index b7d13d16b..b5437c093 100644 --- a/meilisearch-http/src/routes/indexes/documents.rs +++ b/meilisearch-http/src/routes/indexes/documents.rs @@ -88,12 +88,12 @@ pub fn configure(cfg: &mut web::ServiceConfig) { } pub async fn get_document( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, ) -> Result { let index = path.index_uid.clone(); let id = path.document_id.clone(); - let document = data + let document = meilisearch .document(index, id, None as Option>) .await?; debug!("returns: {:?}", document); @@ -120,7 +120,7 @@ pub struct BrowseQuery { } pub async fn get_all_documents( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, params: web::Query, ) -> Result { @@ -136,7 +136,7 @@ pub async fn get_all_documents( Some(names) }); - let documents = data + let documents = meilisearch .documents( path.index_uid.clone(), params.offset.unwrap_or(DEFAULT_RETRIEVE_DOCUMENTS_OFFSET), @@ -157,7 +157,7 @@ pub struct UpdateDocumentsQuery { /// Route used when the payload type is "application/json" /// Used to add or replace documents pub async fn add_documents( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, params: web::Query, body: Payload, @@ -169,7 +169,7 @@ pub async fn add_documents( method: IndexDocumentsMethod::ReplaceDocuments, format: DocumentAdditionFormat::Json, }; - let update_status = data + let update_status = meilisearch .register_update(path.index_uid.as_str(), update) .await?; @@ -180,7 +180,7 @@ pub async fn add_documents( /// Route used when the payload type is "application/json" /// Used to add or replace documents pub async fn update_documents( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, params: web::Query, body: Payload, @@ -192,7 +192,7 @@ pub async fn update_documents( method: IndexDocumentsMethod::UpdateDocuments, format: DocumentAdditionFormat::Json, }; - let update_status = data + let update_status = meilisearch .register_update(path.index_uid.as_str(), update) .await?; diff --git a/meilisearch-http/src/routes/indexes/mod.rs b/meilisearch-http/src/routes/indexes/mod.rs index da7008640..2bf8afa08 100644 --- a/meilisearch-http/src/routes/indexes/mod.rs +++ b/meilisearch-http/src/routes/indexes/mod.rs @@ -76,16 +76,16 @@ pub struct UpdateIndexResponse { } pub async fn get_index( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, ) -> Result { - let meta = data.get_index(path.index_uid.clone()).await?; + let meta = meilisearch.get_index(path.index_uid.clone()).await?; debug!("returns: {:?}", meta); Ok(HttpResponse::Ok().json(meta)) } pub async fn update_index( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, body: web::Json, ) -> Result { @@ -95,7 +95,7 @@ pub async fn update_index( uid: body.uid, primary_key: body.primary_key, }; - let meta = data + let meta = meilisearch .update_index(path.into_inner().index_uid, settings) .await?; debug!("returns: {:?}", meta); @@ -111,10 +111,10 @@ pub async fn update_index( //} pub async fn get_index_stats( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, ) -> Result { - let response = data.get_index_stats(path.index_uid.clone()).await?; + let response = meilisearch.get_index_stats(path.index_uid.clone()).await?; debug!("returns: {:?}", response); Ok(HttpResponse::Ok().json(response)) diff --git a/meilisearch-http/src/routes/indexes/search.rs b/meilisearch-http/src/routes/indexes/search.rs index 2b68e6ed6..1ae8eb2f7 100644 --- a/meilisearch-http/src/routes/indexes/search.rs +++ b/meilisearch-http/src/routes/indexes/search.rs @@ -82,13 +82,13 @@ impl From for SearchQuery { } pub async fn search_with_url_query( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, params: web::Query, ) -> Result { debug!("called with params: {:?}", params); let query = params.into_inner().into(); - let search_result = data.search(path.into_inner().index_uid, query).await?; + let search_result = meilisearch.search(path.into_inner().index_uid, query).await?; // Tests that the nb_hits is always set to false #[cfg(test)] @@ -99,12 +99,12 @@ pub async fn search_with_url_query( } pub async fn search_with_post( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, params: web::Json, ) -> Result { debug!("search called with params: {:?}", params); - let search_result = data + let search_result = meilisearch .search(path.into_inner().index_uid, params.into_inner()) .await?; diff --git a/meilisearch-http/src/routes/indexes/updates.rs b/meilisearch-http/src/routes/indexes/updates.rs index 547977790..cfef5ba63 100644 --- a/meilisearch-http/src/routes/indexes/updates.rs +++ b/meilisearch-http/src/routes/indexes/updates.rs @@ -37,11 +37,11 @@ pub struct UpdateParam { } pub async fn get_update_status( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, ) -> Result { let params = path.into_inner(); - let meta = data + let meta = meilisearch .update_status(params.index_uid, params.update_id) .await?; let meta = UpdateStatusResponse::from(meta); @@ -50,10 +50,10 @@ pub async fn get_update_status( } pub async fn get_all_updates_status( - data: GuardedData, + meilisearch: GuardedData, path: web::Path, ) -> Result { - let metas = data.all_update_status(path.into_inner().index_uid).await?; + let metas = meilisearch.all_update_status(path.into_inner().index_uid).await?; let metas = metas .into_iter() .map(UpdateStatusResponse::from) diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index a38689bd9..ff8681498 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -233,8 +233,8 @@ pub async fn running() -> HttpResponse { HttpResponse::Ok().json(serde_json::json!({ "status": "MeiliSearch is running" })) } -async fn get_stats(data: GuardedData) -> Result { - let response = data.get_all_stats().await?; +async fn get_stats(meilisearch: GuardedData) -> Result { + let response = meilisearch.get_all_stats().await?; debug!("returns: {:?}", response); Ok(HttpResponse::Ok().json(response)) @@ -248,7 +248,7 @@ struct VersionResponse { pkg_version: String, } -async fn get_version(_data: GuardedData) -> HttpResponse { +async fn get_version(_meilisearch: GuardedData) -> HttpResponse { let commit_sha = option_env!("VERGEN_GIT_SHA").unwrap_or("unknown"); let commit_date = option_env!("VERGEN_GIT_COMMIT_TIMESTAMP").unwrap_or("unknown"); @@ -265,8 +265,8 @@ struct KeysResponse { public: Option, } -pub async fn list_keys(data: GuardedData) -> HttpResponse { - let api_keys = (*data).clone(); +pub async fn list_keys(meilisearch: GuardedData) -> HttpResponse { + let api_keys = (*meilisearch).clone(); HttpResponse::Ok().json(&KeysResponse { private: api_keys.private, public: api_keys.public,