lambda

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 6 Imported by: 0

README

LambdaHelpers

A slightly less than random set of functions used to simplify using AWS' golang lambda libraries

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accept added in v0.1.2

func Accept(request events.APIGatewayV2HTTPRequest) []string

Accept parses the "accept" header and reqturns an array with the accepted content types

func Accepts added in v0.1.2

func Accepts(available []string, request events.APIGatewayV2HTTPRequest) (string, error)

Accepts returns the best content type given a list of available types and a list of accepted types.

func CreatedResponse added in v0.1.1

func CreatedResponse() (events.APIGatewayV2HTTPResponse, error)

CreatedResponse returns a basic "created" response. The error return value is *always* nil to satisfy the requirements of the lambda handler.

func ErrorResponse

func ErrorResponse(message, body string, err error, status int, logger zerolog.Logger) (events.APIGatewayV2HTTPResponse, error)

ErrorResponse returns a response object with a user defined error. The messane and error are written to the log at Error level. The error return value is *always* nil to satisfy the requirements of the lambda handler. The value of the `body` parameter is used as the body of the response. If this an empty string, the string value of the error will be used instead. Any additional values in logValues are written to the log after the initial values

func ForbiddenResponse

func ForbiddenResponse(message, what string, logger zerolog.Logger) (events.APIGatewayV2HTTPResponse, error)

ForbiddenResponse returns a response object set to Forbidden. The `what` parameter can be set to the object access is denied to or the user or whatever is convenient. The `message` and `what` parameters are written to the log at Warning level. The error return value is *always* nil to satisfy the requirements of the lambda handler. Any additional values in logValues are written to the log after the initial values

func InternalErrorResponse added in v0.1.1

func InternalErrorResponse(message string, err error, logger zerolog.Logger) (events.APIGatewayV2HTTPResponse, error)

InternalErrorResponse returns a response object for an internal error. The `message` and `err` parameters are written to the log with Error level. The error return value is *always* nil to satisfy the requirements of the lambda handler. The body is set to "Internal Server Error" Any additional values in logValues are written to the log after the initial values

func JSONResponse

func JSONResponse(body string, status int) (events.APIGatewayV2HTTPResponse, error)

JSONResponse returns a response object with the content type set to "application/json" and the string value as the body. The error return value is *always* nil to satisfy the requirements of the lambda handler.

func NewResponse

func NewResponse() events.APIGatewayV2HTTPResponse

NewResponse creates a new responses object with the pointer type fields initialised

func NotFoundResponse

func NotFoundResponse(message, what string, logger zerolog.Logger, logValues ...interface{}) (events.APIGatewayV2HTTPResponse, error)

NotFoundResponse returns a response object set to NotFound. The `message“ and `what` parameters are written to the log at Warning level. The error return value is *always* nil to satisfy the requirements of the lambda handler. Any additional values in logValues are written to the log after the initial values

func ResponseWithType

func ResponseWithType(body, contentType string, status int) (events.APIGatewayV2HTTPResponse, error)

ResponseWithType returns a response object with the body and content-type set with the required status

Types

This section is empty.

Jump to

Keyboard shortcuts

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