header 를 이용한 api 버전관리

This commit is contained in:
haerong22
2020-11-28 14:56:35 +09:00
parent 6ffa54dedd
commit 9e97a3b269

View File

@@ -33,7 +33,9 @@ public class AdminController {
// GET /admin/user/1 -> version 추가
// @GetMapping("/v1/users/{id}")
@GetMapping(value = "/users/{id}/", params = "version=1")
// @GetMapping(value = "/users/{id}/", params = "version=1")
// @GetMapping(value = "/users/{id}", headers = "X-API-VERSION=1")
@GetMapping(value = "/users/{id}", produces = "application/vnd.company.appv1+json")
public MappingJacksonValue retrieveUserV1(@PathVariable int id) {
User user = userDaoService.findOne(id);
@@ -51,7 +53,9 @@ public class AdminController {
return mapping;
}
// @GetMapping("/v2/users/{id}")
@GetMapping(value = "/users/{id}/", params = "version=2")
// @GetMapping(value = "/users/{id}/", params = "version=2")
// @GetMapping(value = "/users/{id}", headers = "X-API-VERSION=2")
@GetMapping(value = "/users/{id}", produces = "application/vnd.company.appv2+json")
public MappingJacksonValue retrieveUserV2(@PathVariable int id) {
User user = userDaoService.findOne(id);