v1.15.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2020 License: MIT Imports: 4 Imported by: 5



Package apigateway provides a standard serialization format to wrap API Gateway responses that translate into specific end-user errors.



This section is empty.


This section is empty.


This section is empty.


type Error

type Error struct {
	Code    int                    `json:"code"`
	Err     string                 `json:"err"`
	Message string                 `json:"message"`
	Context map[string]interface{} `json:"context,omitempty"`

Error represents an error to return in response to an API Gateway request.

func NewErrorResponse

func NewErrorResponse(statusCode int, messages ...interface{}) *Error

NewErrorResponse returns a response that satisfies the regular expression used to determine integration mappings via the API Gateway. messages is a stringable type. Error interface instances will be properly typecast.

func (*Error) Error

func (apigError *Error) Error() string

Error returns the JSONified version of this error which will trigger the appropriate integration mapping.

type Response added in v1.6.0

type Response struct {
	Code    int               `json:"code,omitempty"`
	Body    interface{}       `json:"body,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`

Response is the type returned by an API Gateway function. Note that a non 2xx HTTP status code should be returned as a Response type rather than an Error. Errors should be reserved for Lambda functions that fail to execute.

func NewResponse added in v1.6.0

func NewResponse(code int, body interface{}, headers ...map[string]string) *Response

NewResponse returns an API Gateway response object

func (*Response) MarshalJSON added in v1.6.0

func (resp *Response) MarshalJSON() ([]byte, error)

MarshalJSON is a custom marshaller to ensure that the marshalled headers are always lowercase

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL