BAEL-3200 Error handling with Spring AMQP

This commit is contained in:
Alexander Molochko
2019-10-17 03:01:56 +03:00
parent db85c8f275
commit 70d5e7c57d
20386 changed files with 1639315 additions and 0 deletions
@@ -0,0 +1,48 @@
package com.baeldung.cachecontrol;
import com.baeldung.cachecontrol.model.TimestampDto;
import com.baeldung.cachecontrol.model.UserDto;
import org.springframework.http.CacheControl;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.concurrent.TimeUnit;
@Controller
public class ResourceEndpoint {
@GetMapping(value = "/default/users/{name}")
public ResponseEntity<UserDto> getUserWithDefaultCaching(@PathVariable String name) {
return ResponseEntity.ok(new UserDto(name));
}
@GetMapping("/users/{name}")
public ResponseEntity<UserDto> getUser(@PathVariable String name) {
return ResponseEntity
.ok()
.cacheControl(CacheControl.maxAge(60, TimeUnit.SECONDS))
.body(new UserDto(name));
}
@GetMapping("/timestamp")
public ResponseEntity<TimestampDto> getServerTimestamp() {
return ResponseEntity
.ok()
.cacheControl(CacheControl.noStore())
.body(new TimestampDto(LocalDateTime
.now()
.toInstant(ZoneOffset.UTC)
.toEpochMilli()));
}
@GetMapping("/private/users/{name}")
public ResponseEntity<UserDto> getUserNotCached(@PathVariable String name) {
return ResponseEntity
.ok()
.body(new UserDto(name));
}
}