Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/main/java/co/zeroae/gate/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Objects;

/**
Expand Down Expand Up @@ -71,9 +72,20 @@ public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent in
* @param responseType One of the supported response types
*/
private String encode(Document doc, String responseType) throws IOException {
final FeatureMap exportOptions = Factory.newFeatureMap();

// Take *all* annotation types.
final AnnotationSet defaultAnnots = doc.getAnnotations();
final HashSet<String> annotationTypes = new HashSet<>();
for (Annotation annotation: defaultAnnots.inDocumentOrder()) {
annotationTypes.add(annotation.getType());
}
exportOptions.put("annotationTypes", annotationTypes);

final ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (responseType.equals("application/json")) {
gateJsonExporter.export(doc, baos);
gateJsonExporter.setAnnotationTypes(doc.getAnnotationSetNames());
gateJsonExporter.export(doc, baos, exportOptions);
return baos.toString();
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/co/zeroae/gate/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testApplicationJsonResponse() throws Exception {
APIGatewayProxyRequestEvent input = new APIGatewayProxyRequestEvent()
.withHttpMethod("POST")
.withHeaders(Collections.unmodifiableMap(inputHeaders))
.withBody("My name is Lambda Function and I approve this test.");
.withBody("Today is Monday.");
final TestContext context = new TestContext();
final APIGatewayProxyResponseEvent result = app.handleRequest(input, context);
assertEquals(result.getStatusCode().intValue(), 200);
Expand Down