This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent() | |
.withHeaders(headers); | |
try { | |
final String pageContents = this.getPageContents("https://checkip.amazonaws.com"); | |
String output = String | |
.format("{ \"message\": \"hello world\", \"location\": \"%s\" }", pageContents); | |
return response.withStatusCode(200).withBody(output); | |
} catch (IOException e) { | |
return response.withBody("{}").withStatusCode(500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resources: | |
HelloWorldFunction: | |
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction | |
Properties: | |
CodeUri: HelloWorldFunction | |
Handler: helloworld.App::handleRequest | |
Runtime: java11 | |
MemorySize: 512 | |
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object | |
Variables: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final String NEWS_URL = "https://news.google.com/news/rss"; | |
private static final HttpClient HTTP_CLIENT = HttpClient.newBuilder() | |
.version(Version.HTTP_2) | |
.followRedirects(HttpClient.Redirect.NORMAL) | |
.connectTimeout(Duration.ofSeconds(10)) | |
.build(); | |
private String getNewsFromGoogle() | |
throws IOException, InterruptedException, XMLStreamException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<properties> | |
<maven.compiler.source>11</maven.compiler.source> | |
<maven.compiler.target>11</maven.compiler.target> | |
</properties> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class NewsItem { | |
private String title; | |
private String pubDate; | |
public String getTitle() { | |
return title; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
final String output = getNewsFromGoogle(); | |
return response.withStatusCode(200).withBody(output); | |
} catch (final IOException | InterruptedException | XMLStreamException e) { | |
return response.withBody("{}").withStatusCode(500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assertTrue(content.contains("\"title\"")); | |
assertTrue(content.contains("\"date\"")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<groupId>petstore</groupId> | |
<artifactId>PetStore</artifactId> | |
<version>1.0</version> | |
<packaging>jar</packaging> | |
<properties> | |
<maven.compiler.source>11</maven.compiler.source> | |
<maven.compiler.target>11</maven.compiler.target> | |
</properties> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.petstore.model; | |
public final class Pet { | |
private String id; | |
private String name; | |
private int age; | |
private String category; | |
// Getters and Setters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>software.amazon.awssdk</groupId> | |
<artifactId>dynamodb</artifactId> | |
<version>2.15.12</version> | |
</dependency> | |
<dependency> | |
<groupId>software.amazon.awssdk</groupId> | |
<artifactId>apache-client</artifactId> | |
<version>2.5.12</version> | |
</dependency> |
OlderNewer