GH-206 Ensured consistency in header names

added Copyright/aithor tags

Resolves #206
This commit is contained in:
Oleg Zhurakousky
2018-09-12 22:10:10 +02:00
parent 40b542edfe
commit e1c2610105

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.function.adapter.aws;
import java.util.HashMap;
@@ -10,10 +26,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.function.context.catalog.FunctionInspector;
import org.springframework.http.HttpStatus;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.GenericMessage;
/**
*
* @author Dave Syer
* @author Oleg Zhurakousky
*
*/
public class SpringBootApiGatewayRequestHandler extends
SpringBootRequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
@@ -69,12 +92,12 @@ public class SpringBootApiGatewayRequestHandler extends
if (functionReturnsMessage(output)) {
Message<?> message = (Message<?>) output;
return new APIGatewayProxyResponseEvent().withStatusCode(
(Integer) message.getHeaders().getOrDefault("statusCode", 200))
(Integer) message.getHeaders().getOrDefault("statuscode", HttpStatus.OK.value()))
.withHeaders(toResponseHeaders(message.getHeaders()))
.withBody(serializeBody(message.getPayload()));
}
else {
return new APIGatewayProxyResponseEvent().withStatusCode(200)
return new APIGatewayProxyResponseEvent().withStatusCode(HttpStatus.OK.value())
.withBody(serializeBody(output));
}