From fcc7cfd9ac0329dfcfaeb2d1d718f28a72f10438 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Thu, 27 Nov 2025 14:58:56 +0100 Subject: [PATCH] feat: message broadcast endpoint mapping --- .../server/api/UpdateMessagingController.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 server/src/main/java/server/api/UpdateMessagingController.java diff --git a/server/src/main/java/server/api/UpdateMessagingController.java b/server/src/main/java/server/api/UpdateMessagingController.java new file mode 100644 index 0000000..d4b01f2 --- /dev/null +++ b/server/src/main/java/server/api/UpdateMessagingController.java @@ -0,0 +1,30 @@ +package server.api; + +import commons.Recipe; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.messaging.handler.annotation.MessageMapping; +import org.springframework.messaging.handler.annotation.SendTo; +import org.springframework.messaging.simp.SimpMessagingTemplate; +import org.springframework.stereotype.Controller; + +@Controller +public class UpdateMessagingController { + private final RecipeController recipeController; + @Autowired + public UpdateMessagingController( + RecipeController recipeController) { + this.recipeController = recipeController; + } + + /** + * Mapping for STOMP: SEND /updates/recipe + * @param recipe The request body as a new {@link Recipe} object to update the original into + * @return The updated {@link Recipe} object wrapped in a {@link org.springframework.http.ResponseEntity}. + */ + @MessageMapping("/updates/recipe") + @SendTo("/subscribe/recipe") + public ResponseEntity broadcastRecipeUpdate(Recipe recipe) { + return recipeController.updateRecipe(recipe.getId(), recipe); + } +}