use actix_session::Session; use actix_web::{get, web, HttpResponse}; use crate::templates; use crate::{Pinussy, Result}; #[get("/")] async fn get(session: Session, state: web::Data) -> Result { let username: Option; if let Some(user_id) = session.get::("user_id")? { username = Some( sqlx::query!("select username from users where id = $1", user_id) .fetch_one(&state.db) .await? .username, ) } else { username = None } return Ok(HttpResponse::Ok().body(render!(templates::home_html, username).unwrap())); }