wip: get all posts route working state

This commit is contained in:
2024-09-25 18:29:12 -04:00
parent 7842baf5f2
commit 9bd2cf373a
5 changed files with 72 additions and 43 deletions

View File

@@ -19,21 +19,21 @@ impl CommentsRoute {
pub fn routes(app_state: &AppState) -> axum::Router {
// add more comment routes here!
axum::Router::new()
.route("/post/:id", get(CommentsRoute::get_post_comments))
.route("/add", post(CommentsRoute::insert_comment))
.with_state(app_state.db)
// .route("/post/:id", get(CommentsRoute::get_post_comments))
// .route("/add", post(CommentsRoute::insert_comment))
.with_state(app_state.db.clone())
}
async fn get_post_comments(State(pool): State<PgPool>) -> Json<()> {
let results = CommentsDatasource::get_posts_comments(pool).await;
Json {}
}
async fn insert_comment(
State(pool): State<PgPool>,
Form(comment_input): Form<CommentInput>,
) -> bool {
let results = CommentsDatasource::insert_comment(pool, comment_input).await;
true
}
// async fn get_post_comments(State(pool): State<PgPool>) -> Json<()> {
// let results = CommentsDatasource::get_posts_comments(pool).await;
// Json {}
// }
//
// async fn insert_comment(
// State(pool): State<PgPool>,
// Form(comment_input): Form<CommentInput>,
// ) -> bool {
// let results = CommentsDatasource::insert_comment(pool, comment_input).await;
// true
// }
}