aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes.rs')
-rw-r--r--src/routes.rs30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/routes.rs b/src/routes.rs
index fc4426a..9054fb6 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -4,12 +4,15 @@ use crate::custom_filters;
4use crate::handlers; 4use crate::handlers;
5use crate::schema::Db; 5use crate::schema::Db;
6 6
7// Root, all routes combined 7/// Root, all routes combined
8pub fn consensus_routes(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 8pub fn consensus_routes(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
9 transaction_list(db.clone()).or(transaction_propose(db.clone())) 9 transaction_list(db.clone())
10 .or(transaction_propose(db.clone()))
11 .or(block_propose(db.clone()))
12 .or(block_list(db.clone()))
10} 13}
11 14
12// GET /transaction 15/// GET /transaction
13pub fn transaction_list(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 16pub fn transaction_list(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
14 warp::path!("transaction") 17 warp::path!("transaction")
15 .and(warp::get()) 18 .and(warp::get())
@@ -17,15 +20,32 @@ pub fn transaction_list(db: Db) -> impl Filter<Extract = impl Reply, Error = Rej
17 .and_then(handlers::list_transactions) 20 .and_then(handlers::list_transactions)
18} 21}
19 22
20// POST /transaction 23/// GET /block
24pub fn block_list(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
25 warp::path!("block")
26 .and(warp::get())
27 .and(custom_filters::with_db(db))
28 .and_then(handlers::list_blocks)
29}
30
31/// POST /transaction
21pub fn transaction_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 32pub fn transaction_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
22 warp::path!("transaction") 33 warp::path!("transaction")
23 .and(warp::post()) 34 .and(warp::post())
24 .and(custom_filters::json_body()) 35 .and(custom_filters::transaction_json_body())
25 .and(custom_filters::with_db(db)) 36 .and(custom_filters::with_db(db))
26 .and_then(handlers::propose_transaction) 37 .and_then(handlers::propose_transaction)
27} 38}
28 39
40/// POST /block
41pub fn block_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
42 warp::path!("block")
43 .and(warp::post())
44 .and(custom_filters::block_json_body())
45 .and(custom_filters::with_db(db))
46 .and_then(handlers::propose_block)
47}
48
29/////////////////////////// 49///////////////////////////
30// below are not mine. // 50// below are not mine. //
31/////////////////////////// 51///////////////////////////