feat: message broadcast endpoint mapping
This commit is contained in:
parent
dcb76612d5
commit
fcc7cfd9ac
1 changed files with 30 additions and 0 deletions
|
|
@ -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: <code>SEND /updates/recipe</code>
|
||||||
|
* @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<Recipe> broadcastRecipeUpdate(Recipe recipe) {
|
||||||
|
return recipeController.updateRecipe(recipe.getId(), recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue