summaryrefslogtreecommitdiff
path: root/server/src/routes
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-08-22 17:30:28 +0200
committerSanto Cariotti <santo@dcariotti.me>2022-08-22 17:30:28 +0200
commitd346c13beb54baa334326d80bb4ba2e48653ce06 (patch)
tree22ddb47fc2dd57647fd8ee339c6b6be4f8494889 /server/src/routes
parent5b32f1eb39f14457a11701095218524fc50f5a73 (diff)
Routes for users
Diffstat (limited to 'server/src/routes')
-rw-r--r--server/src/routes/mod.rs1
-rw-r--r--server/src/routes/user.rs13
2 files changed, 14 insertions, 0 deletions
diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs
new file mode 100644
index 0000000..22d12a3
--- /dev/null
+++ b/server/src/routes/mod.rs
@@ -0,0 +1 @@
+pub mod user;
diff --git a/server/src/routes/user.rs b/server/src/routes/user.rs
new file mode 100644
index 0000000..f155f27
--- /dev/null
+++ b/server/src/routes/user.rs
@@ -0,0 +1,13 @@
+use crate::errors::AppError;
+use crate::models::user::User;
+use axum::{routing::get, Json, Router};
+
+pub fn create_route() -> Router {
+ Router::new().route("/", get(list_users))
+}
+
+async fn list_users() -> Result<Json<Vec<User>>, AppError> {
+ let users = User::list().await?;
+
+ Ok(Json(users))
+}