diff --git a/api_responses/api_responses.go b/api_responses/api_responses.go index b728cb5f0ba6bac519729c12c1b5edde4006c800..768113b595f16cc1844461546d297473f3c42e93 100644 --- a/api_responses/api_responses.go +++ b/api_responses/api_responses.go @@ -20,6 +20,8 @@ import ( "github.com/aws/aws-lambda-go/events" ) +var ContentTypeJSONHeader = map[string]string{"Content-Type": "application/json"} + type errorMsg struct { Message string `json:"message"` Error string `json:"error,omitempty"` @@ -255,3 +257,12 @@ func StatusCodeFromSQLError(err error) int { return http.StatusInternalServerError } } + +func GenericJSONResponseWithContentAndHeaders(code int, content string, headers map[string]string) events.APIGatewayProxyResponse { + response := events.APIGatewayProxyResponse{ + StatusCode: code, + Body: content, + Headers: map_utils.MergeMaps(utils.CorsHeaders(), ContentTypeJSONHeader, headers), + } + return response +}