summaryrefslogtreecommitdiffstats
path: root/src/routes/users.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/users.rs')
-rw-r--r--src/routes/users.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/routes/users.rs b/src/routes/users.rs
new file mode 100644
index 0000000..2ad9ede
--- /dev/null
+++ b/src/routes/users.rs
@@ -0,0 +1,16 @@
+use actix_web::{get, web, HttpResponse};
+
+use crate::templates;
+use crate::users::User;
+use crate::{Pinussy, Result};
+
+#[get("/users")]
+async fn get(state: web::Data<Pinussy>) -> Result<HttpResponse> {
+ let users: Vec<User> = sqlx::query_as("select * from users")
+ .fetch_all(&state.db)
+ .await
+ // TODO: no unwrap
+ .unwrap();
+ println!("lol");
+ Ok(HttpResponse::Ok().body(render!(templates::users_html, users).unwrap()))
+}