Grokking Spring Boot
0% completed
API Versioning
@GetMapping(path = "/{id}", version /* v1 */ = "1") public BookingResponse get(@PathVariable @Positive long id) { return bookings.find(id).map(BookingResponse::from) .orElseThrow(() -> new BookingNotFoundException(id)); } @GetMapping(path = "/{id}", version /* v2 */ = "2") public BookingResponseV2 getV2(@PathVariable @Positive long id) { return bookings.find(id).map(BookingResponseV2::from) .orElseThrow(() -> new BookingNotFoundException(id)); }
Two methods in BookingController now map the same request, GET /bookings/{id}
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%