January 2018
Intermediate to advanced
414 pages
10h 29m
English
When we define how to answer POST requests, we specify that instead of returning a 200 OK, we should answer a simply 201 CREATED, and we really don't need to specify a body for our request since we are not returning any object back.
We can modify our method as:
@PostMapping(value = "/customer/")fun createCustomer(@RequestBody customer: Customer): ResponseEntity<Unit> { customerService.createCustomer(customer) return ResponseEntity(Unit, HttpStatus.CREATED)}
In this scenario, we are set to use a ResponseEntity using Unit, the equivalent in Kotlin of a void type, since we are not going to output anybody.
Read now
Unlock full access