Skip to content

Commit

Permalink
delete message by id endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsundin committed Jan 30, 2024
1 parent dc22c4a commit 9348b4f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/Controller/SocialMediaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public Javalin startAPI() {
app.get("/messages", this::getAllMessages);
app.get("/messages/{message_id}", this::getMessageById);
app.post("/messages", this::messages);
app.delete("/messages/{message_id}", this::deleteMessageById);

return app;
}
Expand Down Expand Up @@ -125,6 +126,17 @@ private void getMessageById(Context context) {
}
}

private void deleteMessageById(Context context) {
int message_id = Integer.parseInt(context.pathParam("message_id"));
Message message = messageService.deleteMessageById(message_id);
if (message == null) {
context.status(200);
}
else {
context.json(message);
}
}

private void getAccountTable(Context context) {
List<Account> accounts = accountService.getAllAccounts();
context.json(accounts);
Expand Down

0 comments on commit 9348b4f

Please sign in to comment.