diff --git a/src/main/java/Controller/SocialMediaController.java b/src/main/java/Controller/SocialMediaController.java index 865bdff..9a594c2 100644 --- a/src/main/java/Controller/SocialMediaController.java +++ b/src/main/java/Controller/SocialMediaController.java @@ -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; } @@ -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 accounts = accountService.getAllAccounts(); context.json(accounts);