Sparta: github.com/mweagle/Sparta/aws/apigateway Index | Files

package apigateway

import "github.com/mweagle/Sparta/aws/apigateway"

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

Index

Package Files

doc.go response.go

type Error Uses

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 Uses

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 Uses

func (apigError *Error) Error() string

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

type Response Uses

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 Uses

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

NewResponse returns an API Gateway response object

func (*Response) MarshalJSON Uses

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

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

Package apigateway imports 4 packages (graph) and is imported by 1 packages. Updated 2019-02-10. Refresh now. Tools for package owners.