/query returns map with hashes
parent
c0c240256a
commit
302f435c5d
|
@ -60,9 +60,16 @@ pub async fn get_query(
|
||||||
|
|
||||||
let sexp = lexpr::from_str(info.query.as_str()).map_err(ErrorBadRequest)?;
|
let sexp = lexpr::from_str(info.query.as_str()).map_err(ErrorBadRequest)?;
|
||||||
let in_query = Query::try_from(&sexp).map_err(ErrorBadRequest)?;
|
let in_query = Query::try_from(&sexp).map_err(ErrorBadRequest)?;
|
||||||
let result = query(&connection, in_query).map_err(ErrorInternalServerError)?;
|
let entries = query(&connection, in_query).map_err(ErrorInternalServerError)?;
|
||||||
|
let mut result: HashMap<String, Entry> = HashMap::new();
|
||||||
|
for entry in entries {
|
||||||
|
result.insert(
|
||||||
|
encode(entry.hash().map_err(ErrorInternalServerError)?),
|
||||||
|
entry,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().json(result))
|
Ok(HttpResponse::Ok().json(&result))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/api/obj/{address_str}")]
|
#[get("/api/obj/{address_str}")]
|
||||||
|
|
Loading…
Reference in New Issue