January 2018
Intermediate to advanced
414 pages
10h 29m
English
We have used @RequestMapping in our example, giving the method as a parameter to the annotation, and that is okay but maybe it is too much code for such a simple thing; Spring provides helpers to reduce this declaration:
@GetMapping(value = "/customer/{id}")fun getCustomer(@PathVariable id : Int) = customers[id]
For a GET request, we could use @GetMapping, and we don't need to specify the method; there are equivalent annotations for POST, PUT, and DELETE, @PostMapping, @PutMapping, and @DeleteMapping respectively.
Now with this final change, we complete our verbs code, but we can see some level of duplication in our PUT verb which doesn't look right, so we probably need to explore concepts about how we can ...
Read now
Unlock full access