Further aligning the API & implementation.

- Completed implementation of /beacon/head
 - renamed 'latest_finalized_checkpoint' to 'current_finalized_checkpoint' for consistency
 - Reorganised list of endpoints in both spec & router so that they match
 - Fixed the content-type modifications for /metrics
 - Added a new 'RFC' tag to the spec, to tag things that we have not implemented and aren't sure if it's useful.
 - Moved 'deposit_contract' under /spec
This commit is contained in:
Luke Anderson
2019-08-28 21:25:38 +10:00
parent 16ec330a79
commit 77e2f576af
4 changed files with 128 additions and 97 deletions

View File

@@ -1,5 +1,6 @@
use crate::{success_response, ApiError, ApiResult, DBPath};
use beacon_chain::{BeaconChain, BeaconChainTypes};
use http::HeaderValue;
use hyper::{Body, Request};
use prometheus::{Encoder, TextEncoder};
use std::sync::Arc;
@@ -67,10 +68,10 @@ pub fn get_prometheus<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiR
.map(|string| {
let mut response = success_response(Body::from(string));
// Need to change the header to text/plain for prometheius
response
.headers_mut()
.insert("content-type", "text/plain; charset=utf-8".parse().unwrap())
.unwrap();
response.headers_mut().insert(
"content-type",
HeaderValue::from_static("text/plain; charset=utf-8"),
);
response
})
.map_err(|e| ApiError::ServerError(format!("Failed to encode prometheus info: {:?}", e)))