summaryrefslogtreecommitdiffstats
path: root/src/routes/users.rs
blob: 2ad9ede9961d43b832542e45ec8009501d030aef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()))
}