diff options
| -rw-r--r-- | src/handlers.rs | 6 | ||||
| -rw-r--r-- | src/routes.rs | 9 | 
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. | ||
| 357 | pub 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 | 
| 357 | pub async fn list_transactions(db: Db) -> Result<impl warp::Reply, Infallible> { | 363 | pub 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 | ||
| 33 | pub 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 | 
| 32 | pub fn list_users(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { | 41 | pub fn list_users(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { | 
| 33 | warp::path!("user") | 42 | warp::path!("user") | 
