lambda

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AWSRequestToHTTPRequest

func AWSRequestToHTTPRequest(ctx context.Context, event LambdaRequest) (*http.Request, error)

Types

type LambdaHandlerFunc

type LambdaHandlerFunc func(
	ctx context.Context, event LambdaRequest,
) (LambdaResponse, error)

LambdaHandlerFunc is a generic LambdaHandlerFunc for incoming http requests/events incoming request will be run through http server which will return the response

func LambdaHandler

func LambdaHandler(handler http.Handler, logger *logrus.Logger) LambdaHandlerFunc

type LambdaRequest

type LambdaRequest struct {
	events.ALBTargetGroupRequest   //nolint // ambiguous selectors declared below
	events.APIGatewayV2HTTPRequest //nolint // ambiguous selectors declared below

	// Added to resolve "ambiguous selectors" error
	Headers               map[string]string `json:"headers"`
	QueryStringParameters map[string]string `json:"queryStringParameters"`
	RequestContext        RequestContext    `json:"requestContext"`
	Body                  string            `json:"body"`
	IsBase64Encoded       bool              `json:"isBase64Encoded"`
}

LambdaRequest wraps ALBTargetGroupRequest and APIGatewayV2HTTPRequest into a generic request struct

type LambdaResponse

type LambdaResponse struct {
	StatusCode        int                 `json:"statusCode"`
	Headers           map[string]string   `json:"headers"`
	MultiValueHeaders map[string][]string `json:"multiValueHeaders"`
	Body              string              `json:"body"`
	IsBase64Encoded   bool                `json:"isBase64Encoded"`
	Cookies           []string            `json:"cookies"`
}

LambdaRequest mimics ALBTargetGroupResponse and APIGatewayV2HTTPResponse into a generic response struct

type ProxyResponseWriter

type ProxyResponseWriter struct {
	// contains filtered or unexported fields
}

ProxyResponseWriter implements http.ResponseWriter and adds the method necessary to return an events.ALBTargetGroupResponse object

func NewProxyResponseWriter

func NewProxyResponseWriter() *ProxyResponseWriter

NewProxyResponseWriter returns a new ProxyResponseWriter object. The object is initialized with an empty map of headers and a status code of -1

func (*ProxyResponseWriter) CloseNotify

func (r *ProxyResponseWriter) CloseNotify() <-chan bool

func (*ProxyResponseWriter) GetLambdaResponse

func (r *ProxyResponseWriter) GetLambdaResponse() (LambdaResponse, error)

GetLambdaResponse converts the data passed to the response writer into an LambdaResponse object. Returns a populated lambda response object. If the response is invalid, for example has no headers or an invalid status code returns an error.

func (*ProxyResponseWriter) Header

func (r *ProxyResponseWriter) Header() http.Header

Header implementation from the http.ResponseWriter interface.

func (*ProxyResponseWriter) Write

func (r *ProxyResponseWriter) Write(body []byte) (int, error)

Write sets the response body in the object. If no status code was set before with the WriteHeader method it sets the status for the response to 200 OK.

func (*ProxyResponseWriter) WriteHeader

func (r *ProxyResponseWriter) WriteHeader(status int)

WriteHeader sets a status code for the response. This method is used for error responses.

Jump to

Keyboard shortcuts

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