File tree 1 file changed +7
-2
lines changed
start/hello-world/src/main/java/com/example/helloworld/controller
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 18
18
import java .util .stream .Collectors ;
19
19
20
20
@ RestController
21
- @ RequestMapping (value = "/api" , method = RequestMethod . POST )
21
+ @ RequestMapping (value = "/api" )
22
22
public class BookController {
23
23
24
24
private List <Book > books = new ArrayList <>();
@@ -36,8 +36,13 @@ public ResponseEntity deleteBookById(@PathVariable("id") int id) {
36
36
}
37
37
38
38
@ GetMapping ("/book" )
39
- public ResponseEntity getBookByName (@ RequestParam ("name" ) String name ) {
39
+ public ResponseEntity getBookByName (@ RequestParam (value = "name" ) String name ) {
40
40
List <Book > results = books .stream ().filter (book -> book .getName ().equals (name )).collect (Collectors .toList ());
41
41
return ResponseEntity .ok (results );
42
42
}
43
+
44
+ @ GetMapping ("/books" )
45
+ public ResponseEntity getAllBook () {
46
+ return ResponseEntity .ok (books );
47
+ }
43
48
}
You can’t perform that action at this time.
0 commit comments