October 2018
Intermediate to advanced
590 pages
15h 5m
English
Since we will serve the UI from http://localhost:8080/messages, it is better that we separate the path for APIs. Let's put API requests under /api/.
We will need to make the following changes to MessageController:
Here is the updated MessageController:
@Controllerpublic class MessageController { ... @GetMapping("/api/messages") @ResponseBody public ResponseEntity<List<Message>> getMessages() { List<Message> messages = messageService.getMessages(); return ResponseEntity.ok(messages); } @PostMapping("/api/messages") @ResponseBody ...Read now
Unlock full access