summaryrefslogtreecommitdiff
path: root/src/api/posts.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/posts.rs')
-rw-r--r--src/api/posts.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/api/posts.rs b/src/api/posts.rs
index 85ff2b2..6830c1a 100644
--- a/src/api/posts.rs
+++ b/src/api/posts.rs
@@ -18,11 +18,15 @@ impl Check for PostCreateRequest {
async fn create(AuthorizedUser(user): AuthorizedUser, Json(body): Json<PostCreateRequest>) -> Response {
- let Ok(_post) = Post::new(user.user_id, body.content) else {
+ let Ok(post) = Post::new(user.user_id, body.content) else {
return ResponseCode::InternalServerError.msg("Failed to create post")
};
- ResponseCode::Created.msg("Successfully created new post")
+ let Ok(json) = serde_json::to_string(&post) else {
+ return ResponseCode::InternalServerError.msg("Failed to create post")
+ };
+
+ ResponseCode::Created.json(&json)
}
#[derive(Deserialize)]