in software/demofunction/src/main/kotlin/com/app/config/DemoHandler.kt [23:52]
override fun handleRequest(input: APIGatewayProxyRequestEvent, context: Context?): APIGatewayV2HTTPResponse {
val showAppConfigResults = input.queryStringParameters?.getOrDefault("appConfig", "false").toBoolean()
val headers = mapOf(Pair("Content-Type", "application/json"))
if(showAppConfigResults) {
val client = HttpClient.newBuilder().build()
val request = HttpRequest.newBuilder()
.uri(URI.create("http://localhost:2772/applications/${application}/environments/${environment}/configurations/${configuration}"))
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
return APIGatewayV2HTTPResponse.builder()
.withStatusCode(200)
.withHeaders(headers)
.withIsBase64Encoded(false)
.withBody(response.body())
.build()
}
return APIGatewayV2HTTPResponse.builder()
.withStatusCode(200)
.withHeaders(headers)
.withIsBase64Encoded(false)
.withBody(mapper.writeValueAsString(input))
.build()
}