|
3 | 3 | import org.springframework.http.ResponseEntity; |
4 | 4 | import org.springframework.web.bind.annotation.CrossOrigin; |
5 | 5 | import org.springframework.web.bind.annotation.GetMapping; |
| 6 | +import org.springframework.web.bind.annotation.PathVariable; |
6 | 7 | import org.springframework.web.bind.annotation.RequestMapping; |
7 | 8 | import org.springframework.web.bind.annotation.RequestParam; |
8 | 9 | import org.springframework.web.bind.annotation.RestController; |
9 | | -import br.com.developers.controller.handler.github.GithubHandler; |
10 | | -import br.com.developers.github.http.resource.developer.Developer; |
| 10 | +import br.com.developers.github.http.service.developer.GithubService; |
11 | 11 | import lombok.AccessLevel; |
12 | 12 | import lombok.AllArgsConstructor; |
13 | 13 |
|
14 | 14 | @AllArgsConstructor(access = AccessLevel.PACKAGE) |
15 | 15 | @RestController |
16 | 16 | @CrossOrigin(origins = "*") |
17 | | -@RequestMapping("api/github") |
| 17 | +@RequestMapping(GithubController.PATH) |
18 | 18 | public class GithubController { |
19 | 19 |
|
20 | | - private GithubHandler handler; |
| 20 | + protected static final String PATH = "/api/github/"; |
21 | 21 |
|
22 | | - @GetMapping("/search") |
23 | | - public ResponseEntity<Developer> search(@RequestParam(name = "qualifier") String qualifier, |
| 22 | + private GithubService service; |
| 23 | + |
| 24 | + @GetMapping("search/{endpoint}") |
| 25 | + public ResponseEntity<Object> search(@PathVariable(name = "endpoint") String endpoint, |
| 26 | + @RequestParam(name = "qualifier") String qualifier, |
24 | 27 | @RequestParam(name = "sort", required = false) String sort, |
25 | 28 | @RequestParam(name = "order", required = false) String order, |
26 | 29 | @RequestParam(name = "per_page", required = false, defaultValue = "10") int perPage, |
27 | 30 | @RequestParam(name = "page", required = false, defaultValue = "0") int page) { |
28 | | - return handler.searchUser(qualifier, sort, order, perPage, page); |
| 31 | + return service.search(endpoint, qualifier, sort, order, perPage, page); |
29 | 32 | } |
30 | 33 |
|
31 | 34 | } |
0 commit comments