Made async functions work!

- Cleaned up imports
 - Moved ApiError and such to it's own error.rs
 - Obsoleted 'success_response' in favour of new async regular and json only flavours
 - Made ApiError work async and be derived from hyper errors
 - Added a check to ensure an error is thrown if a non-json encoding is requested on a json-only function
 - Made all the individual service functions return futures (only node and network for now)
This commit is contained in:
Luke Anderson
2019-09-11 00:40:22 +10:00
parent b0090df543
commit b8667217f0
10 changed files with 143 additions and 138 deletions

View File

@@ -1,4 +1,5 @@
use crate::{helpers::*, success_response, ApiError, ApiResult, DBPath};
use crate::helpers::*;
use crate::{ApiError, ApiResult, DBPath};
use beacon_chain::BeaconChainTypes;
use http::HeaderValue;
use hyper::{Body, Request};
@@ -62,7 +63,7 @@ pub fn get_prometheus<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiR
String::from_utf8(buffer)
.map(|string| {
let mut response = success_response(Body::from(string));
let mut response = success_response_old(Body::from(string));
// Need to change the header to text/plain for prometheus
response.headers_mut().insert(
"content-type",