using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
namespace Amazon.Lambda.APIGatewayEvents
{
///
/// The response object for Lambda functions handling request from API Gateway HTTP API v2 proxy format
/// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
///
[DataContract]
public class APIGatewayHttpApiV2ProxyResponse
{
///
/// The HTTP status code for the request
///
[DataMember(Name = "statusCode")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("statusCode")]
#endif
public int StatusCode { get; set; }
///
/// The Http headers returned in the response. Multiple header values set for the the same header should be separate by a comma.
///
[DataMember(Name = "headers")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("headers")]
#endif
public IDictionary Headers { get; set; }
///
/// Utility method to set a single or multiple values for a header to the Headers collection.
///
///
///
/// If true it will append the values to the existing value in the Headers collection.
public void SetHeaderValues(string headerName, string value, bool append)
{
SetHeaderValues(headerName, new string[] { value }, append);
}
///
/// Utility method to set a single or multiple values for a header to the Headers collection.
///
///
///
/// If true it will append the values to the existing value in the Headers collection.
public void SetHeaderValues(string headerName, IEnumerable values, bool append)
{
if (this.Headers == null)
this.Headers = new Dictionary();
if(this.Headers.ContainsKey(headerName) && append)
{
this.Headers[headerName] = this.Headers[headerName] + "," + string.Join(",", values);
}
else
{
this.Headers[headerName] = string.Join(",", values);
}
}
///
/// The cookies returned in the response.
///
[DataMember(Name = "cookies")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("cookies")]
#endif
public string[] Cookies { get; set; }
///
/// The response body
///
[DataMember(Name = "body")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("body")]
#endif
public string Body { get; set; }
///
/// Flag indicating whether the body should be treated as a base64-encoded string
///
[DataMember(Name = "isBase64Encoded")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("isBase64Encoded")]
#endif
public bool IsBase64Encoded { get; set; }
}
}