com.amazonaws.serverless.proxy.model.AwsProxyRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-serverless-java-container-core Show documentation
Show all versions of aws-serverless-java-container-core Show documentation
Allows Java applications written for a servlet container to run in AWS Lambda
The newest version!
/*
* Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file 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 com.amazonaws.serverless.proxy.model;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Default implementation of the request object from an API Gateway AWS_PROXY integration
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class AwsProxyRequest {
//-------------------------------------------------------------
// Variables - Private
//-------------------------------------------------------------
private String body;
private String version;
private String resource;
private AwsProxyRequestContext requestContext;
private MultiValuedTreeMap multiValueQueryStringParameters;
private Map queryStringParameters;
private Headers multiValueHeaders;
private SingleValueHeaders headers;
private Map pathParameters;
private String httpMethod;
private Map stageVariables;
private String path;
private boolean isBase64Encoded;
public AwsProxyRequest() {
multiValueHeaders = new Headers();
multiValueQueryStringParameters = new MultiValuedTreeMap<>();
pathParameters = new HashMap<>();
stageVariables = new HashMap<>();
}
//-------------------------------------------------------------
// Methods - Getter/Setter
//-------------------------------------------------------------
@JsonIgnore
public String getQueryString() {
StringBuilder params = new StringBuilder("");
if (this.getMultiValueQueryStringParameters() == null) {
return "";
}
for (String key : this.getMultiValueQueryStringParameters().keySet()) {
for (String val : this.getMultiValueQueryStringParameters().get(key)) {
String separator = params.length() == 0 ? "?" : "&";
params.append(separator + key + "=" + val);
}
}
return params.toString();
}
public RequestSource getRequestSource() {
if (getRequestContext() != null && getRequestContext().getElb() != null) {
return RequestSource.ALB;
}
return RequestSource.API_GATEWAY;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getResource() {
return resource;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public void setResource(String resource) {
this.resource = resource;
}
public AwsProxyRequestContext getRequestContext() {
return requestContext;
}
public void setRequestContext(AwsProxyRequestContext requestContext) {
this.requestContext = requestContext;
}
public MultiValuedTreeMap getMultiValueQueryStringParameters() {
return multiValueQueryStringParameters;
}
public void setMultiValueQueryStringParameters(
MultiValuedTreeMap multiValueQueryStringParameters) {
this.multiValueQueryStringParameters = multiValueQueryStringParameters;
}
public Map getQueryStringParameters() {
return queryStringParameters;
}
public void setQueryStringParameters(Map queryStringParameters) {
this.queryStringParameters = queryStringParameters;
}
public Headers getMultiValueHeaders() {
return multiValueHeaders;
}
public void setMultiValueHeaders(Headers multiValueHeaders) {
this.multiValueHeaders = multiValueHeaders;
}
public SingleValueHeaders getHeaders() {
return headers;
}
public void setHeaders(SingleValueHeaders headers) {
this.headers = headers;
}
public Map getPathParameters() {
return pathParameters;
}
public void setPathParameters(Map pathParameters) {
this.pathParameters = pathParameters;
}
public String getHttpMethod() {
return httpMethod;
}
public void setHttpMethod(String httpMethod) {
this.httpMethod = httpMethod;
}
public Map getStageVariables() {
return stageVariables;
}
public void setStageVariables(Map stageVariables) {
this.stageVariables = stageVariables;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
@JsonProperty("isBase64Encoded")
public boolean isBase64Encoded() {
return isBase64Encoded;
}
public void setIsBase64Encoded(boolean base64Encoded) {
isBase64Encoded = base64Encoded;
}
}