mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
replace body with json
This commit is contained in:
parent
13c5289ff1
commit
3c25ab0d50
4 changed files with 46 additions and 118 deletions
|
@ -81,18 +81,15 @@ async fn search_with_url_query(
|
|||
Ok(q) => q,
|
||||
Err(e) => {
|
||||
return Ok(
|
||||
HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() }))
|
||||
HttpResponse::BadRequest().json(serde_json::json!({ "error": e.to_string() }))
|
||||
)
|
||||
}
|
||||
};
|
||||
let search_result = data.search(path.into_inner().index_uid, query).await;
|
||||
match search_result {
|
||||
Ok(docs) => {
|
||||
let docs = serde_json::to_string(&docs).unwrap();
|
||||
Ok(HttpResponse::Ok().body(docs))
|
||||
}
|
||||
Ok(docs) => Ok(HttpResponse::Ok().json(docs)),
|
||||
Err(e) => {
|
||||
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
Ok(HttpResponse::BadRequest().json(serde_json::json!({ "error": e.to_string() })))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,12 +104,9 @@ async fn search_with_post(
|
|||
.search(path.into_inner().index_uid, params.into_inner())
|
||||
.await;
|
||||
match search_result {
|
||||
Ok(docs) => {
|
||||
let docs = serde_json::to_string(&docs).unwrap();
|
||||
Ok(HttpResponse::Ok().body(docs))
|
||||
}
|
||||
Ok(docs) => Ok(HttpResponse::Ok().json(docs)),
|
||||
Err(e) => {
|
||||
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
Ok(HttpResponse::BadRequest().json(serde_json::json!({ "error": e.to_string() })))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue