Skip to content
Snippets Groups Projects
Commit 1139ae37 authored by Johan de Klerk's avatar Johan de Klerk
Browse files

Added GenericJSONResponseWithContentAndHeaders

parent 7aacf210
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment