Skip to content
Snippets Groups Projects
Commit 7345d888 authored by 장 무현's avatar 장 무현
Browse files

musicSearch

parent f0ff2e22
Branches
No related tags found
No related merge requests found
......@@ -16,13 +16,25 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class MyWebController {
@GetMapping(value="/musicSearch/{term}")
public String musicSearchByPath(@PathVariable String term) {
return "";
public MusicList musicSearchByPath(@PathVariable String term) {
RestTemplate restTemplate = new RestTemplate();
String url = String.format("https://itunes.apple.com/search?term=%s&entity=album", term);
try {
String response = restTemplate.getForObject(url, String.class);
ObjectMapper mapper = new ObjectMapper();
MusicList list = mapper.readValue(response, MusicList.class);
System.out.println(list.getResultCount());
return list;
} catch (IOException e) {
System.out.println(e.toString());
return null;
}
}
@GetMapping(value="/musicSearch")
public MusicList musicSearchByParam(@RequestParam String term) { RestTemplate restTemplate = new RestTemplate();
public MusicList musicSearchByParam(@RequestParam String term) {
RestTemplate restTemplate = new RestTemplate();
String url = String.format("https://itunes.apple.com/search?term=%s&entity=album", term);
try {
String response = restTemplate.getForObject(url, String.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment