Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.amazonaws.serverless.proxy.internal.model.AwsProxyRequest;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import lombok.extern.slf4j.Slf4j;
- import java.io.IOException;
- @Slf4j
- public class ApiGatewayRequest extends AwsProxyRequest {
- private static final ObjectMapper objectMapper = new ObjectMapper();
- public <T> T getBody(Class<T> clazz) {
- try {
- return objectMapper.readValue(getBody(), clazz);
- } catch (IOException e) {
- log.error("Failed to serialize JSON to object", e);
- throw new IllegalStateException(e);
- }
- }
- }
Add Comment
Please, Sign In to add comment