mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
implement retrieve one document
This commit is contained in:
parent
f3d65ec5e9
commit
581dcd5735
5 changed files with 109 additions and 58 deletions
|
@ -55,18 +55,17 @@ async fn get_document(
|
|||
data: web::Data<Data>,
|
||||
path: web::Path<DocumentParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
todo!()
|
||||
//let index = path.index_uid.clone();
|
||||
//let id = path.document_id.clone();
|
||||
//match data.retrieve_document(index, id, None as Option<Vec<String>>).await {
|
||||
//Ok(document) => {
|
||||
//let json = serde_json::to_string(&document).unwrap();
|
||||
//Ok(HttpResponse::Ok().body(json))
|
||||
//}
|
||||
//Err(e) => {
|
||||
//Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
//}
|
||||
//}
|
||||
let index = path.index_uid.clone();
|
||||
let id = path.document_id.clone();
|
||||
match data.retrieve_document(index, id, None as Option<Vec<String>>).await {
|
||||
Ok(document) => {
|
||||
let json = serde_json::to_string(&document).unwrap();
|
||||
Ok(HttpResponse::Ok().body(json))
|
||||
}
|
||||
Err(e) => {
|
||||
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[delete(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue