From 3e13e728aa37a1ea9e83aa6d7c73ed14f5cafb33 Mon Sep 17 00:00:00 2001 From: mpostma Date: Thu, 28 May 2020 19:37:54 +0200 Subject: [PATCH] add post method --- meilisearch-http/src/routes/search.rs | 31 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/meilisearch-http/src/routes/search.rs b/meilisearch-http/src/routes/search.rs index 654d50fcf..4a10ae649 100644 --- a/meilisearch-http/src/routes/search.rs +++ b/meilisearch-http/src/routes/search.rs @@ -3,7 +3,7 @@ use std::collections::{HashSet, HashMap}; use log::warn; use actix_web::web; use actix_web::HttpResponse; -use actix_web_macros::get; +use actix_web_macros::{get, post}; use serde::Deserialize; use serde_json::Value; @@ -36,6 +36,26 @@ struct SearchQuery { facets_distribution: Option, } +#[get("/indexes/{index_uid}/search", wrap = "Authentication::Public")] +async fn search_with_url_query( + data: web::Data, + path: web::Path, + params: web::Query, +) -> Result { + let search_result = params.search(&path.index_uid, data)?; + Ok(HttpResponse::Ok().json(search_result)) +} + +#[post("/indexes/{index_uid}/search", wrap = "Authentication::Public")] +async fn search_with_post( + data: web::Data, + path: web::Path, + params: web::Query, +) -> Result { + let search_result = params.search(&path.index_uid, data)?; + Ok(HttpResponse::Ok().json(search_result)) +} + impl SearchQuery { fn search(&self, index_uid: &str, data: web::Data) -> Result { let index = data @@ -157,15 +177,6 @@ impl SearchQuery { } } -#[get("/indexes/{index_uid}/search", wrap = "Authentication::Public")] -async fn search_with_url_query( - data: web::Data, - path: web::Path, - params: web::Query, -) -> Result { - let search_result = params.search(&path.index_uid, data)?; - Ok(HttpResponse::Ok().json(search_result)) -} /// Parses the incoming string into an array of attributes for which to return a count. It returns /// a Vec of attribute names ascociated with their id.