All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazonaws.serverless.proxy.model.AwsProxyResponse Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show 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;

/**
 * Response object for an API Gateway method using AWS_PROXY integrations
 */
public class AwsProxyResponse {

    //-------------------------------------------------------------
    // Variables - Private
    //-------------------------------------------------------------

    private int statusCode;
    private Map headers;
    private String body;
    private boolean isBase64Encoded;


    //-------------------------------------------------------------
    // Constructors
    //-------------------------------------------------------------

    public AwsProxyResponse() {

    }


    public AwsProxyResponse(int statusCode) {
        this(statusCode, null);
    }


    public AwsProxyResponse(int statusCode, Map headers) {
        this(statusCode, headers, null);
    }


    public AwsProxyResponse(int statusCode, Map headers, String body) {
        this.statusCode = statusCode;
        this.headers = headers;
        this.body = body;
    }


    //-------------------------------------------------------------
    // Methods - Public
    //-------------------------------------------------------------

    public void addHeader(String key, String value) {
        if (this.headers == null) {
            this.headers = new HashMap();
        }

        this.headers.put(key, value);
    }


    //-------------------------------------------------------------
    // Methods - Getter/Setter
    //-------------------------------------------------------------

    public int getStatusCode() {
        return statusCode;
    }


    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }


    public Map getHeaders() {
        return headers;
    }


    public void setHeaders(Map headers) {
        this.headers = headers;
    }


    public String getBody() {
        return body;
    }


    public void setBody(String body) {
        this.body = body;
    }

    public boolean isBase64Encoded() {
        return isBase64Encoded;
    }

    public void setBase64Encoded(boolean base64Encoded) {
        isBase64Encoded = base64Encoded;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy