Formatting.

This commit is contained in:
Ignotus Peverell
2017-05-31 14:44:44 -07:00
parent f79fb8ef95
commit 996eab72ae
13 changed files with 221 additions and 207 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ use rest::Error;
pub fn get<'a, T>(url: &'a str) -> Result<T, Error>
where for<'de> T: Deserialize<'de>
{
println!("get {}", url);
println!("get {}", url);
let client = hyper::Client::new();
let res = check_error(client.get(url).send())?;
serde_json::from_reader(res)
+9 -5
View File
@@ -72,9 +72,11 @@ impl ApiEndpoint for OutputApi {
}
fn get(&self, id: String) -> ApiResult<Output> {
debug!("GET output {}", id);
let c = util::from_hex(id.clone()).map_err(|e| Error::Argument(format!("Not a valid commitment: {}", id)))?;
self.chain_store.get_output_by_commit(&Commitment::from_vec(c)).map_err(|e| Error::Internal(e.to_string()))
debug!("GET output {}", id);
let c = util::from_hex(id.clone()).map_err(|e| Error::Argument(format!("Not a valid commitment: {}", id)))?;
self.chain_store
.get_output_by_commit(&Commitment::from_vec(c))
.map_err(|e| Error::Internal(e.to_string()))
}
}
@@ -84,8 +86,10 @@ pub fn start_rest_apis(addr: String, chain_store: Arc<chain::ChainStore>) {
thread::spawn(move || {
let mut apis = ApiServer::new("/v1".to_string());
apis.register_endpoint("/chain".to_string(), ChainApi { chain_store: chain_store.clone() });
apis.register_endpoint("/chain/output".to_string(), OutputApi { chain_store: chain_store.clone() });
apis.register_endpoint("/chain".to_string(),
ChainApi { chain_store: chain_store.clone() });
apis.register_endpoint("/chain/output".to_string(),
OutputApi { chain_store: chain_store.clone() });
apis.start(&addr[..]).unwrap_or_else(|e| {
error!("Failed to start API HTTP server: {}.", e);
});