use axum::{ extract::{Path, State}, response::Html, Json, }; use maud::{html, Render}; use sqlx::{Pool, Postgres}; use uuid::Uuid; use crate::model::{Chat, Message}; pub async fn get( Path(url_path): Path, State(pool): State>, ) -> Json> { let chat = sqlx::query_as!(Chat, r#"select * from chats where url_path = $1"#, url_path) .fetch_one(&pool) .await .unwrap(); let messages = sqlx::query_as!( Message, r#"select * from messages where chat_id = $1"#, chat.id ) .fetch_all(&pool) .await .unwrap(); Json(messages) }