Documentation ¶
Overview ¶
Package shim provides a thin layer between the Lambda API Gateway integrations and the standard library `http.Handler` interface. Bring your own router.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAPIGatewayProxyResponse ¶
func NewAPIGatewayProxyResponse(rw *ResponseWriter) events.APIGatewayProxyResponse
NewAPIGatewayProxyResponse converts a shim.ResponseWriter into an events.APIGatewayProxyResponse
func NewHTTPRequest ¶
func NewHTTPRequest(ctx context.Context, event events.APIGatewayProxyRequest) (*http.Request, error)
NewHTTPRequest creates an *http.Request from a context.Context and an events.APIGatewayProxyRequest
func SetDebugLogger ¶
SetDebugLogger is an option function to set the debug logger on a Shim. The debug logger gives insight into the event received from APIGateway and how shim transforms the request and response.
Types ¶
type Handler ¶
type Handler interface {
Handle(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
}
Handler is an interface for accepting and responding to API Gateway integration requests
type Log ¶
type Log interface { Printf(format string, v ...interface{}) Println(v ...interface{}) }
Log is a simple logging interface that is satisfied by the standard library logger amongst other idiomatic loggers
type ResponseWriter ¶
ResponseWriter adheres to the http.ResponseWriter interface and makes the HTTP Status Code, Headers, and Body publicly accessible
func NewResponseWriter ¶
func NewResponseWriter() *ResponseWriter
NewResponseWriter returns an ResponseWriter with the headers properly initialized
func (*ResponseWriter) Header ¶
func (rw *ResponseWriter) Header() http.Header
Header adheres the http.ResponseWriter interface
func (*ResponseWriter) Write ¶
func (rw *ResponseWriter) Write(b []byte) (int, error)
Write adheres to the io.Writer interface
func (*ResponseWriter) WriteHeader ¶
func (rw *ResponseWriter) WriteHeader(c int)
WriteHeader adheres to the http.ResponseWriter interface
type Shim ¶
Shim provides a thin layer between your traditional http.Handler based application and AWS Lambda + API Gateway.
func (*Shim) Handle ¶
func (s *Shim) Handle(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
Handle converts an APIGatewayProxyRequest converts an APIGatewayProxyRequest into an http.Request and passes it to the given http.Handler along with a ResponseWriter. The response from the handler is converted into an APIGatewayProxyResponse.