let mime = mime_guess::from_path(path).first_or_octet_stream();
Ok(
Response::builder()
.header(header::CONTENT_TYPE, mime.as_ref())
.body(body)
.unwrap(),
)
}
async fn block_count(Extension(index): Extension<Arc<Index>>) -> ServerResult<String> {
Ok(index.block_count()?.to_string())
}
async fn block_height(Extension(index): Extension<Arc<Index>>) -> ServerResult<String> {
Ok(
index
.block_height()?
.ok_or_not_found(|| "blockheight")?
.to_string(),
)
}
async fn block_hash(Extension(index): Extension<Arc<Index>>) -> ServerResult<String> {
Ok(
index
.block_hash(None)?
.ok_or_not_found(|| "blockhash")?
.to_string(),
)
}
async fn block_hash_json(Extension(index): Extension<Arc<Index>>) -> ServerResult<Json<String>> {
Ok(Json(
index
.block_hash(None)?
.ok_or_not_found(|| "blockhash")?
.to_string(),
))
}
async fn block_hash_from_height(