aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornecrashter2022-04-23 16:07:55 +0300
committerYigit Sever2022-04-23 18:10:12 +0300
commit8d7a1c4337af570c691c3c16527b724ae57ed80f (patch)
tree17ecde85510c7322aa390f98c73446431e66a906 /src
parentbc0c945be9a76613ee89ce94e9b979b9ac0bf373 (diff)
downloadgradecoin-8d7a1c4337af570c691c3c16527b724ae57ed80f.tar.gz
gradecoin-8d7a1c4337af570c691c3c16527b724ae57ed80f.tar.bz2
gradecoin-8d7a1c4337af570c691c3c16527b724ae57ed80f.zip
GET /config endpoint
Diffstat (limited to 'src')
-rw-r--r--src/handlers.rs6
-rw-r--r--src/routes.rs9
2 files changed, 15 insertions, 0 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index d2a834f..44c5299 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -352,6 +352,12 @@ pub async fn authenticate_user(
352 Ok(warp::reply::with_status(res_json, StatusCode::CREATED)) 352 Ok(warp::reply::with_status(res_json, StatusCode::CREATED))
353} 353}
354 354
355/// GET /config
356/// Returns the configuration settings of this network in JSON.
357pub async fn get_config(db: Db) -> Result<impl warp::Reply, Infallible> {
358 Ok(reply::with_status(reply::json(&db.config), StatusCode::OK))
359}
360
355/// GET /transaction 361/// GET /transaction
356/// Returns JSON array of transactions 362/// Returns JSON array of transactions
357pub async fn list_transactions(db: Db) -> Result<impl warp::Reply, Infallible> { 363pub async fn list_transactions(db: Db) -> Result<impl warp::Reply, Infallible> {
diff --git a/src/routes.rs b/src/routes.rs
index 9eadbea..651626a 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -19,6 +19,7 @@ pub fn network(db: Db) -> BoxedFilter<(impl Reply,)> {
19 }; 19 };
20 root.and( 20 root.and(
21 transaction_list(db.clone()) 21 transaction_list(db.clone())
22 .or(get_config_route(db.clone()))
22 .or(register_user(db.clone())) 23 .or(register_user(db.clone()))
23 .or(auth_transaction_propose(db.clone())) 24 .or(auth_transaction_propose(db.clone()))
24 .or(auth_block_propose(db.clone())) 25 .or(auth_block_propose(db.clone()))
@@ -28,6 +29,14 @@ pub fn network(db: Db) -> BoxedFilter<(impl Reply,)> {
28 .boxed() 29 .boxed()
29} 30}
30 31
32/// GET /config warp route
33pub fn get_config_route(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
34 warp::path!("config")
35 .and(warp::get())
36 .and(custom_filters::with_db(db))
37 .and_then(handlers::get_config)
38}
39
31/// GET /user warp route 40/// GET /user warp route
32pub fn list_users(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 41pub fn list_users(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
33 warp::path!("user") 42 warp::path!("user")