File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
src/main/java/com/jap/rest101/controller Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 44import com .jap .rest101 .db .repository .UserRepository ;
55import lombok .RequiredArgsConstructor ;
66import org .springframework .http .ResponseEntity ;
7- import org .springframework .web .bind .annotation .PostMapping ;
8- import org .springframework .web .bind .annotation .RequestBody ;
9- import org .springframework .web .bind .annotation .RequestMapping ;
10- import org .springframework .web .bind .annotation .RestController ;
7+ import org .springframework .web .bind .annotation .*;
8+
9+ import java .util .List ;
1110
1211@ RestController
1312@ RequestMapping ("/users" )
@@ -21,5 +20,11 @@ public ResponseEntity<User> createUser(@RequestBody User user) {
2120 repository .save (user );
2221 return ResponseEntity .ok (user );
2322 }
23+
24+ @ GetMapping
25+ public ResponseEntity <List <User >> listUser () {
26+ List <User > users = repository .findAll ();
27+ return ResponseEntity .ok (users );
28+ }
2429}
2530
You can’t perform that action at this time.
0 commit comments