diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2023-01-27 16:04:04 -0500 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2023-01-27 16:04:04 -0500 |
commit | 8536e41c64811630ce8c99eb49d81f89bfb69456 (patch) | |
tree | 4066f9e7dc47fbda4b6aa74871d26ebbe3a43d26 /src/api/posts.rs | |
parent | input length and range checking (diff) | |
download | xssbook-8536e41c64811630ce8c99eb49d81f89bfb69456.tar.gz xssbook-8536e41c64811630ce8c99eb49d81f89bfb69456.tar.bz2 xssbook-8536e41c64811630ce8c99eb49d81f89bfb69456.zip |
rusty boio finished
Diffstat (limited to 'src/api/posts.rs')
-rw-r--r-- | src/api/posts.rs | 8 |
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)] |