Quick placeholder api route index (#286) (#324)

* Aiming for #286 - quick placeholder to have at least something to help your memory

* corrections:pool/push get->post, add sumtrees/(roots|lastutxos|lastrangeproofs|lastkernels)
This commit is contained in:
Simon B 2017-11-19 21:24:14 +01:00 committed by AntiochP
parent 08a277f8d1
commit 7986829d58

View file

@ -35,6 +35,21 @@ use util;
use util::LOGGER; use util::LOGGER;
// RESTful index of available api endpoints
// GET /v1/
struct IndexHandler {
list: Vec<String>,
}
impl IndexHandler {
}
impl Handler for IndexHandler {
fn handle(&self, _req: &mut Request) -> IronResult<Response> {
json_response_pretty(&self.list)
}
}
// Supports retrieval of multiple outputs in a single request - // Supports retrieval of multiple outputs in a single request -
// GET /v1/chain/utxos?id=xxx,yyy,zzz // GET /v1/chain/utxos?id=xxx,yyy,zzz
// GET /v1/chain/utxos?id=xxx&id=yyy&id=zzz // GET /v1/chain/utxos?id=xxx&id=yyy&id=zzz
@ -317,7 +332,22 @@ pub fn start_rest_apis<T>(
p2p_server: p2p_server.clone(), p2p_server: p2p_server.clone(),
}; };
let route_list = vec!(
"get /".to_string(),
"get /chain".to_string(),
"get /chain/utxos".to_string(),
"get /sumtrees/roots".to_string(),
"get /sumtrees/lastutxos?n=10".to_string(),
"get /sumtrees/lastrangeproofs".to_string(),
"get /sumtrees/lastkernels".to_string(),
"get /pool".to_string(),
"post /pool/push".to_string(),
"get /peers/all".to_string(),
"get /peers/connected".to_string(),
);
let index_handler = IndexHandler { list: route_list };
let router = router!( let router = router!(
index: get "/" => index_handler,
chain_tip: get "/chain" => chain_tip_handler, chain_tip: get "/chain" => chain_tip_handler,
chain_utxos: get "/chain/utxos" => utxo_handler, chain_utxos: get "/chain/utxos" => utxo_handler,
sumtree_roots: get "/sumtrees/*" => sumtree_handler, sumtree_roots: get "/sumtrees/*" => sumtree_handler,