Skip to content

Commit 3af6c03

Browse files
committed
Update BookController.java
1 parent 599e9f5 commit 3af6c03

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: start/hello-world/src/main/java/com/example/helloworld/controller/BookController.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.stream.Collectors;
1919

2020
@RestController
21-
@RequestMapping(value = "/api",method = RequestMethod.POST)
21+
@RequestMapping(value = "/api")
2222
public class BookController {
2323

2424
private List<Book> books = new ArrayList<>();
@@ -36,8 +36,13 @@ public ResponseEntity deleteBookById(@PathVariable("id") int id) {
3636
}
3737

3838
@GetMapping("/book")
39-
public ResponseEntity getBookByName(@RequestParam("name") String name) {
39+
public ResponseEntity getBookByName(@RequestParam(value = "name") String name) {
4040
List<Book> results = books.stream().filter(book -> book.getName().equals(name)).collect(Collectors.toList());
4141
return ResponseEntity.ok(results);
4242
}
43+
44+
@GetMapping("/books")
45+
public ResponseEntity getAllBook() {
46+
return ResponseEntity.ok(books);
47+
}
4348
}

0 commit comments

Comments
 (0)