File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
lesson_26/api/java/api_app/src/main/java/com/codedifferently/lesson26/web Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 7
7
import java .io .IOException ;
8
8
import java .util .List ;
9
9
import java .util .Set ;
10
+ import org .springframework .http .ResponseEntity ;
10
11
import org .springframework .web .bind .annotation .CrossOrigin ;
11
12
import org .springframework .web .bind .annotation .GetMapping ;
12
13
import org .springframework .web .bind .annotation .RestController ;
13
14
14
15
@ RestController
15
16
@ CrossOrigin
16
17
public class MediaItemsController {
18
+
17
19
private final Library library ;
18
20
private final Librarian librarian ;
19
21
@@ -23,10 +25,10 @@ public MediaItemsController(Library library) throws IOException {
23
25
}
24
26
25
27
@ GetMapping ("/items" )
26
- public GetMediaItemsResponse getItems () {
28
+ public ResponseEntity < GetMediaItemsResponse > getItems () {
27
29
Set <MediaItem > items = library .search (SearchCriteria .builder ().build ());
28
30
List <MediaItemResponse > responseItems = items .stream ().map (MediaItemResponse ::from ).toList ();
29
31
var response = GetMediaItemsResponse .builder ().items (responseItems ).build ();
30
- return response ;
32
+ return ResponseEntity . ok ( response ) ;
31
33
}
32
34
}
You can’t perform that action at this time.
0 commit comments