December 2017
Intermediate to advanced
260 pages
7h 34m
English
The MessageController handles all the URLs, or you can say operations, related to messages. To have a separation of concern in our code. The actual job of saving the message, that is the database operations, is delegated to the respective Repository class (MessageRepository):
/** * Exposes the operations related to creating and showing * messages through URLs using REST */ @RestController @RequestMapping("/message") class MessageController(val repository: MessageRepository) { val broadcaster = ReactiveBroadcaster() /** * Creates new message and saves it into DB */ @PostMapping @ResponseStatus(CREATED) fun create(@RequestBody message: Message): Message { val msg = repository.insert(message) broadcaster.send(msg) return ...
Read now
Unlock full access