Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8613bc5

Browse files
add: Versioning through custom headers
1 parent 1426e0f commit 8613bc5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/main/java/com/springboot/blog/controller/PostController.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public PostResponse getAllPosts(
7777
responseCode = "200",
7878
description = "Http Status 200 SUCCESS"
7979
)
80-
@GetMapping(value = "/api/posts/{id}", params = "version=1")
80+
@GetMapping(value = "/api/posts/{id}", headers = {"X-API-VERSION=1"})
8181
public ResponseEntity<PostDto> getPostIdV1(@PathVariable(name = "id") long id) {
8282
return ResponseEntity.ok(postService.getPostById(id));
8383
}
@@ -91,7 +91,7 @@ public ResponseEntity<PostDto> getPostIdV1(@PathVariable(name = "id") long id) {
9191
responseCode = "200",
9292
description = "Http Status 200 SUCCESS"
9393
)
94-
@GetMapping(value = "/api/posts/{id}", params = "version=2")
94+
@GetMapping(value = "/api/posts/{id}", headers = {"X-API-VERSION=2"})
9595
public ResponseEntity<PostDtoV2> getPostIdV2(@PathVariable(name = "id") long id) {
9696
PostDto postDto = postService.getPostById(id);
9797
PostDtoV2 postDtoV2 = new PostDtoV2();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /