GH-574 Fix String wrapping for input/output for AWS APIGateway
As suggested by the user we were improperly wrapping the String payload for input/output during APIGateway interaction Resolves #574
This commit is contained in:
@@ -100,7 +100,7 @@ public class FunctionInvoker implements RequestStreamHandler {
|
|||||||
response.put("statusDescription", httpStatus.toString());
|
response.put("statusDescription", httpStatus.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
String body = new String(responseMessage.getPayload(), StandardCharsets.UTF_8).replaceAll("\"", "");
|
String body = new String(responseMessage.getPayload(), StandardCharsets.UTF_8).replaceAll("\\\"", "\"");
|
||||||
response.put("body", body);
|
response.put("body", body);
|
||||||
|
|
||||||
Map<String, String> responseHeaders = new HashMap<>();
|
Map<String, String> responseHeaders = new HashMap<>();
|
||||||
@@ -193,7 +193,7 @@ public class FunctionInvoker implements RequestStreamHandler {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Object body = requestMap.remove("body");
|
Object body = requestMap.remove("body");
|
||||||
body = body instanceof String ? ("\"" + body + "\"").getBytes(StandardCharsets.UTF_8) : mapper.writeValueAsBytes(body);
|
body = body instanceof String ? String.valueOf(body).getBytes(StandardCharsets.UTF_8) : mapper.writeValueAsBytes(body);
|
||||||
messageBuilder = MessageBuilder.withPayload(body).copyHeaders(requestMap);
|
messageBuilder = MessageBuilder.withPayload(body).copyHeaders(requestMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ public class FunctionInvokerTests {
|
|||||||
invoker.handleRequest(targetStream, output, null);
|
invoker.handleRequest(targetStream, output, null);
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
||||||
assertThat(result.get("body")).isEqualTo("HELLO");
|
assertThat(result.get("body")).isEqualTo("\"HELLO\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@@ -605,7 +605,7 @@ public class FunctionInvokerTests {
|
|||||||
invoker.handleRequest(targetStream, output, null);
|
invoker.handleRequest(targetStream, output, null);
|
||||||
|
|
||||||
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
||||||
assertThat(result.get("body")).isEqualTo("JIM LAHEY");
|
assertThat(result.get("body")).isEqualTo("\"JIM LAHEY\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@@ -621,7 +621,7 @@ public class FunctionInvokerTests {
|
|||||||
|
|
||||||
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
assertThat(result.get("body")).isEqualTo("hello");
|
assertThat(result.get("body")).isEqualTo("\"hello\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@@ -637,7 +637,7 @@ public class FunctionInvokerTests {
|
|||||||
|
|
||||||
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
assertThat(result.get("body")).isEqualTo("hello");
|
assertThat(result.get("body")).isEqualTo("\"hello\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@@ -653,7 +653,7 @@ public class FunctionInvokerTests {
|
|||||||
|
|
||||||
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
assertThat(result.get("body")).isEqualTo("hello");
|
assertThat(result.get("body")).isEqualTo("\"hello\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
|
|||||||
Reference in New Issue
Block a user