-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovieController.java
More file actions
29 lines (22 loc) · 930 Bytes
/
Copy pathMovieController.java
File metadata and controls
29 lines (22 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package devsathi.movies;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@RestController
@RequestMapping("/api/v1/movies")
@CrossOrigin(origins="http://localhost:3000")
public class MovieController {
@Autowired
private MovieService movieService;
@GetMapping
public ResponseEntity<List<Movie>> getAllMovies() { //to get all movies
return new ResponseEntity<List<Movie>>(movieService.allMovies(), HttpStatus.OK);
}
@GetMapping("/{imdbId}")
public ResponseEntity<Optional<Movie>> getSingleMovie(@PathVariable String imdbId){
return new ResponseEntity<Optional<Movie>>(movieService.singleMovie(imdbId),HttpStatus.OK);
}
}