-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Assim mostra o status da requisição, bom para testes.
@GetMapping
public ResponseEntity<List<Anime>> list() {;
return new ResponseEntity<>(animeService.listAll(), HttpStatus.OK);
// return ResponseEntity.ok(animeService.listAll()); // outro jeito de fazer
}By adding / changing the application to yml extension, I can avoid a stack of errors shows up to the frontend:
On application.yml file:
server:
error:
include-stacktrace: neverThere are others optiosn to add to include-stacktrace!
AnimeService file:
@Service
public class AnimeService {
private List<Anime> animes = List.of(new Anime(1L, "Dragon Ball (Test - Build - Hot Swap)"), new Anime(2L, "Bersek"));
public List<Anime> listAll() {
return animes;
}
public Anime findById(long id) {
return animes.stream()
.filter(anime -> anime.getId().equals(id))
.findFirst()
.orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "Anime not found"));
}
}
