From d346c13beb54baa334326d80bb4ba2e48653ce06 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 22 Aug 2022 17:30:28 +0200 Subject: Routes for users --- server/src/routes/mod.rs | 1 + server/src/routes/user.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 server/src/routes/mod.rs create mode 100644 server/src/routes/user.rs (limited to 'server/src/routes') 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>, AppError> { + let users = User::list().await?; + + Ok(Json(users)) +} -- cgit v1.2.3-18-g5258