January 2018
Intermediate to advanced
414 pages
10h 29m
English
Much like the DELETE request, when we update a customer, we should take care if the resource exists, and again we will not need to return anybody for this request; however, if we modified the resource, we should return a 202 ACCEPTED.
Let's modify the update method:
@PutMapping(value = "/customer/{id}")fun updateCustomer(@PathVariable id: Int, @RequestBody customer: Customer): ResponseEntity<Unit> { var status = HttpStatus.NOT_FOUND if (customerService.getCustomer(id) != null) { customerService.updateCustomer(id, customer) status = HttpStatus.ACCEPTED } return ResponseEntity(Unit, status)}
With this method, we have to complete our status responses, but there is one thing more that we could clear up.
Read now
Unlock full access