aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--src/handlers.rs13
-rw-r--r--src/routes.rs8
3 files changed, 22 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8e3ec60..1e1fcf5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
1[package] 1[package]
2name = "gradecoin" 2name = "gradecoin"
3version = "0.2.0" 3version = "0.2.1"
4authors = ["Yigit Sever <yigit@ceng.metu.edu.tr>", 4authors = ["Yigit Sever <yigit@ceng.metu.edu.tr>",
5 "İlker Işık (necrashter) <iiilker99@gmail.com>", 5 "İlker Işık (necrashter) <iiilker99@gmail.com>",
6 "Alperen Keleş <alpkeles99@gmail.com>"] 6 "Alperen Keleş <alpkeles99@gmail.com>"]
diff --git a/src/handlers.rs b/src/handlers.rs
index 93781e4..ae82441 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -361,6 +361,19 @@ pub async fn get_config(db: Db) -> Result<impl warp::Reply, Infallible> {
361 Ok(reply::with_status(reply::json(&db.config), StatusCode::OK)) 361 Ok(reply::with_status(reply::json(&db.config), StatusCode::OK))
362} 362}
363 363
364/// GET /version
365/// Returns the current project version, as defined in Cargo.toml
366pub async fn get_version() -> Result<impl warp::Reply, Infallible> {
367 Ok(reply::with_status(
368 reply::html(format!(
369 "{} - version {}",
370 env!("CARGO_PKG_NAME"),
371 env!("CARGO_PKG_VERSION")
372 )),
373 StatusCode::OK,
374 ))
375}
376
364/// GET /transaction 377/// GET /transaction
365/// Returns JSON array of transactions 378/// Returns JSON array of transactions
366pub async fn list_transactions(db: Db) -> Result<impl warp::Reply, Infallible> { 379pub async fn list_transactions(db: Db) -> Result<impl warp::Reply, Infallible> {
diff --git a/src/routes.rs b/src/routes.rs
index 0df3470..9e08a27 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -23,6 +23,7 @@ pub fn network(db: Db) -> BoxedFilter<(impl Reply,)> {
23 root.and( 23 root.and(
24 transaction_list(db.clone()) 24 transaction_list(db.clone())
25 .or(get_config_route(db.clone())) 25 .or(get_config_route(db.clone()))
26 .or(get_version())
26 .or(register_user(db.clone())) 27 .or(register_user(db.clone()))
27 .or(auth_transaction_propose(db.clone())) 28 .or(auth_transaction_propose(db.clone()))
28 .or(auth_block_propose(db.clone())) 29 .or(auth_block_propose(db.clone()))
@@ -40,6 +41,13 @@ pub fn get_config_route(db: Db) -> impl Filter<Extract = impl Reply, Error = Rej
40 .and_then(handlers::get_config) 41 .and_then(handlers::get_config)
41} 42}
42 43
44/// GET /version warp route
45pub fn get_version() -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
46 warp::path!("version")
47 .and(warp::get())
48 .and_then(handlers::get_version)
49}
50
43/// GET /user warp route 51/// GET /user warp route
44pub fn list_users(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone { 52pub fn list_users(db: Db) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
45 warp::path!("user") 53 warp::path!("user")