use actix_web::{get, post, web, HttpResponse}; use serde::{Deserialize, Serialize}; use serde_json::Value; use crate::error::ResponseError; use crate::helpers::Authentication; use crate::routes::IndexParam; use crate::Data; pub fn services(cfg: &mut web::ServiceConfig) { cfg.service(search_with_post).service(search_with_url_query); } #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SearchQuery { q: Option, offset: Option, limit: Option, attributes_to_retrieve: Option, attributes_to_crop: Option, crop_length: Option, attributes_to_highlight: Option, filters: Option, matches: Option, facet_filters: Option, 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 { todo!() } #[derive(Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SearchQueryPost { _q: Option, _offset: Option, _limit: Option, _attributes_to_retrieve: Option>, _attributes_to_crop: Option>, _crop_length: Option, _attributes_to_highlight: Option>, _filters: Option, _matches: Option, _facet_filters: Option, _facets_distribution: Option>, } #[post("/indexes/{index_uid}/search", wrap = "Authentication::Public")] async fn search_with_post( _data: web::Data, _path: web::Path, _params: web::Json, ) -> Result { todo!() }