use crate::{datasources::posts::PostsDatasource, AppState}; use axum::{extract::State, routing::get, Json, Router}; use sqlx::PgPool; pub struct PostsRoute; impl PostsRoute { pub fn routes(app_state: &AppState) -> Router { // add more post routes here! Router::new() .route("/", get(PostsRoute::get_all)) .route("/:id", get(PostsRoute::get_one)) .with_state(app_state.db) } // get all posts async fn get_all(State(pool): State) -> Json<()> { let results = PostsDatasource::get_all(pool).await; Json {} } // get one post async fn get_one(State(pool): State) -> Json<()> { let results = PostsDatasource::get_one(pool).await; Json {} } // get the top three posts with the highest view count async fn get_popular_posts(State(pool): State) -> Json<()> {} // get the top three posts with the most comments async fn get_hot_posts(State(pool): State) -> Json<()> {} }