use axum::http::StatusCode; use axum::Json; use diesel::{Connection, PgConnection}; use crate::config; use crate::database::model::Match; #[axum::debug_handler] pub async fn get_all() -> Result>, StatusCode> { let mut conn = PgConnection::establish(config::DATABASE_URL()) .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; let matches = Match::all(&mut conn) .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; Ok(Json(matches)) }