11package com .baeldung .cachecontrol ;
22
3-
43import com .baeldung .cachecontrol .model .TimestampDto ;
54import com .baeldung .cachecontrol .model .UserDto ;
65import org .springframework .http .CacheControl ;
@@ -21,23 +20,29 @@ public ResponseEntity<UserDto> getUserWithDefaultCaching(@PathVariable String na
2120 return ResponseEntity .ok (new UserDto (name ));
2221 }
2322
24- @ GetMapping (value = "/users/{name}" )
23+ @ GetMapping ("/users/{name}" )
2524 public ResponseEntity <UserDto > getUser (@ PathVariable String name ) {
26- return ResponseEntity .ok ()
27- .cacheControl (CacheControl .maxAge (60 , TimeUnit .SECONDS ))
28- .body (new UserDto (name ));
25+ return ResponseEntity
26+ .ok ()
27+ .cacheControl (CacheControl .maxAge (60 , TimeUnit .SECONDS ))
28+ .body (new UserDto (name ));
2929 }
3030
31- @ GetMapping (value = "/timestamp" )
31+ @ GetMapping ("/timestamp" )
3232 public ResponseEntity <TimestampDto > getServerTimestamp () {
33- return ResponseEntity .ok ()
34- .cacheControl (CacheControl .noStore ())
35- .body (new TimestampDto (LocalDateTime .now ().toInstant (ZoneOffset .UTC ).toEpochMilli ()));
33+ return ResponseEntity
34+ .ok ()
35+ .cacheControl (CacheControl .noStore ())
36+ .body (new TimestampDto (LocalDateTime
37+ .now ()
38+ .toInstant (ZoneOffset .UTC )
39+ .toEpochMilli ()));
3640 }
3741
38- @ GetMapping (value = "/private/users/{name}" )
42+ @ GetMapping ("/private/users/{name}" )
3943 public ResponseEntity <UserDto > getUserNotCached (@ PathVariable String name ) {
40- return ResponseEntity .ok ()
41- .body (new UserDto (name ));
44+ return ResponseEntity
45+ .ok ()
46+ .body (new UserDto (name ));
4247 }
4348}
0 commit comments