@RequestMapping(value = "/book", method = RequestMethod.POST) public ResponseEntity<Boolean> addBook(@RequestBody Book book) { libraryService.addBook(book); return new ResponseEntity<Boolean>(true, HttpStatus.CREATED); }
@PostConstruct private void populateLibrary() { addBook(new Book("The Hobbit", "J. R. R. Tolkien", LocalDate.of(1937, 2, 21))); addBook(new Book("A Confederacy of Dunces", "John Kennedy Toole", LocalDate.of(1980, 4, 1))); addBook(new Book("A Game of Thrones (A Song of Ice and Fire)", "George R.R. Martin", LocalDate.of(1996, 1, 1))); }