January 2018
Intermediate to advanced
414 pages
10h 29m
English
So far, Spring has handled our response status, every method that we have created will answer with a 200 OK, but we need to modify our responses so we can give a range of different statuses, as we described at the beginning of this section. Spring provides a generic class named ResponseEntity for this, and we can use it to specify our status when we answer back in our controller.
To understand better, we can modify one of our methods:
package com.microservices.chapter3import org.springframework.beans.factory.annotation.Autowiredimport org.springframework.http.HttpStatusimport org.springframework.http.ResponseEntityimport org.springframework.web.bind.annotation.*@RestControllerclass CustomerController { @Autowired private ...Read now
Unlock full access