implement retrieve one document

This commit is contained in:
mpostma 2021-03-04 15:09:00 +01:00
parent f3d65ec5e9
commit 581dcd5735
No known key found for this signature in database
GPG key ID: CBC8A7C1D7A28C3A
5 changed files with 109 additions and 58 deletions

View file

@ -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(