From 7986829d58d6d6818dfabb77cba487ef7f2a4016 Mon Sep 17 00:00:00 2001 From: Simon B Date: Sun, 19 Nov 2017 21:24:14 +0100 Subject: [PATCH] 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) --- api/src/handlers.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/api/src/handlers.rs b/api/src/handlers.rs index cba7994dc..7a6ae4580 100644 --- a/api/src/handlers.rs +++ b/api/src/handlers.rs @@ -35,6 +35,21 @@ use util; use util::LOGGER; +// RESTful index of available api endpoints +// GET /v1/ +struct IndexHandler { + list: Vec, +} + +impl IndexHandler { +} + +impl Handler for IndexHandler { + fn handle(&self, _req: &mut Request) -> IronResult { + json_response_pretty(&self.list) + } +} + // Supports retrieval of multiple outputs in a single request - // GET /v1/chain/utxos?id=xxx,yyy,zzz // GET /v1/chain/utxos?id=xxx&id=yyy&id=zzz @@ -317,7 +332,22 @@ pub fn start_rest_apis( 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!( + index: get "/" => index_handler, chain_tip: get "/chain" => chain_tip_handler, chain_utxos: get "/chain/utxos" => utxo_handler, sumtree_roots: get "/sumtrees/*" => sumtree_handler,