Guest User

Untitled

a guest
Jan 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import com.amazonaws.serverless.proxy.internal.model.AwsProxyRequest;
  2. import com.fasterxml.jackson.databind.ObjectMapper;
  3. import lombok.extern.slf4j.Slf4j;
  4.  
  5. import java.io.IOException;
  6.  
  7. @Slf4j
  8. public class ApiGatewayRequest extends AwsProxyRequest {
  9. private static final ObjectMapper objectMapper = new ObjectMapper();
  10.  
  11. public <T> T getBody(Class<T> clazz) {
  12. try {
  13. return objectMapper.readValue(getBody(), clazz);
  14. } catch (IOException e) {
  15. log.error("Failed to serialize JSON to object", e);
  16. throw new IllegalStateException(e);
  17. }
  18. }
  19. }
Add Comment
Please, Sign In to add comment