|
6 | 6 | import org.springframework.http.CacheControl; |
7 | 7 | import org.springframework.http.ResponseEntity; |
8 | 8 | import org.springframework.stereotype.Controller; |
| 9 | +import org.springframework.web.bind.annotation.GetMapping; |
9 | 10 | import org.springframework.web.bind.annotation.PathVariable; |
10 | | -import org.springframework.web.bind.annotation.RequestMapping; |
11 | | -import org.springframework.web.bind.annotation.RequestMethod; |
12 | 11 |
|
13 | 12 | import java.time.LocalDateTime; |
14 | 13 | import java.time.ZoneOffset; |
|
17 | 16 | @Controller |
18 | 17 | public class ResourceEndpoint { |
19 | 18 |
|
20 | | - @RequestMapping(value = "/default/users/{name}", method = RequestMethod.GET) |
21 | | - public ResponseEntity<UserDto> getUserWithDefaultCaching(@PathVariable(value = "name") String name) { |
| 19 | + @GetMapping(value = "/default/users/{name}") |
| 20 | + public ResponseEntity<UserDto> getUserWithDefaultCaching(@PathVariable String name) { |
22 | 21 | return ResponseEntity.ok(new UserDto(name)); |
23 | 22 | } |
24 | 23 |
|
25 | | - @RequestMapping(value = "/users/{name}", method = RequestMethod.GET) |
26 | | - public ResponseEntity<UserDto> getUser(@PathVariable(value = "name") String name) { |
| 24 | + @GetMapping(value = "/users/{name}") |
| 25 | + public ResponseEntity<UserDto> getUser(@PathVariable String name) { |
27 | 26 | return ResponseEntity.ok() |
28 | 27 | .cacheControl(CacheControl.maxAge(60, TimeUnit.SECONDS)) |
29 | 28 | .body(new UserDto(name)); |
30 | 29 | } |
31 | 30 |
|
32 | | - @RequestMapping(value = "/timestamp", method = RequestMethod.GET) |
| 31 | + @GetMapping(value = "/timestamp") |
33 | 32 | public ResponseEntity<TimestampDto> getServerTimestamp() { |
34 | 33 | return ResponseEntity.ok() |
35 | 34 | .cacheControl(CacheControl.noStore()) |
36 | 35 | .body(new TimestampDto(LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli())); |
37 | 36 | } |
38 | 37 |
|
39 | | - @RequestMapping(value = "/private/users/{name}", method = RequestMethod.GET) |
40 | | - public ResponseEntity<UserDto> getUserNotCached(@PathVariable("name") String name) { |
| 38 | + @GetMapping(value = "/private/users/{name}") |
| 39 | + public ResponseEntity<UserDto> getUserNotCached(@PathVariable String name) { |
41 | 40 | return ResponseEntity.ok() |
42 | 41 | .body(new UserDto(name)); |
43 | 42 | } |
|
0 commit comments