Restructured response builder to give YAML or JSON when SSZ is not available, not just JSON.

This commit is contained in:
Luke Anderson
2019-09-13 20:42:56 +10:00
parent 1dd86baf1a
commit f48311900e
8 changed files with 76 additions and 48 deletions

View File

@@ -7,11 +7,11 @@ use version;
/// Read the version string from the current Lighthouse build.
pub fn get_version(req: Request<Body>) -> ApiResult {
ResponseBuilder::new(&req).body_json(&version::version())
ResponseBuilder::new(&req)?.body_no_ssz(&version::version())
}
/// Read the genesis time from the current beacon chain state.
pub fn get_genesis_time<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiResult {
let beacon_chain = get_beacon_chain_from_request::<T>(&req)?;
ResponseBuilder::new(&req).body(&beacon_chain.head().beacon_state.genesis_time)
ResponseBuilder::new(&req)?.body(&beacon_chain.head().beacon_state.genesis_time)
}