Documentation ¶
Index ¶
- func Configure(conf *Configuration)
- func GetLambdaEvent(ctx context.Context) (*events.APIGatewayProxyRequest, error)
- func GetLambdaEventV2(ctx context.Context) (*events.APIGatewayV2HTTPRequest, error)
- func NewErrorResponse(err error) *events.APIGatewayProxyResponse
- func NewRequest(ctx context.Context, e *events.APIGatewayProxyRequest) (*http.Request, error)
- func NewRequestV2(ctx context.Context, e *events.APIGatewayV2HTTPRequest) (*http.Request, error)
- func ServeOrStartLambda(addr string, h http.Handler) error
- func SetBase64Encoding(w http.ResponseWriter, enabled bool) error
- func Start(h http.Handler)
- type APIGWProxyHeader
- type Configuration
- type Header
- type LambdaHandler
- type LambdaHandlerV2
- type ResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLambdaEvent ¶
func GetLambdaEvent(ctx context.Context) (*events.APIGatewayProxyRequest, error)
GetLambdaEvent from context
func GetLambdaEventV2 ¶ added in v0.2.0
func GetLambdaEventV2(ctx context.Context) (*events.APIGatewayV2HTTPRequest, error)
GetLambdaEventV2 from context
func NewErrorResponse ¶
func NewErrorResponse(err error) *events.APIGatewayProxyResponse
NewErrorResponse create API Gateway Proxy Response contains error message
func NewRequest ¶
NewRequest create http.Request based on API Gateway Proxy request
func NewRequestV2 ¶ added in v0.2.0
NewRequestV2 create http.Request based on API Gateway Proxy request
func ServeOrStartLambda ¶
ServeOrStartLambda will start http server if it's not in lambda environment, otherwise it starts handling lambda
func SetBase64Encoding ¶
func SetBase64Encoding(w http.ResponseWriter, enabled bool) error
SetBase64Encoding overrides base64 encoding for this response see Configuration.SetBase64Encoding
Types ¶
type APIGWProxyHeader ¶
APIGWProxyHeader is format that used by API Gateway to store http header
type Configuration ¶
type Configuration struct {
EncodeResponse bool
}
Configuration customize delta behaviour
type Header ¶
Header wrap normal http.Header and add some converter
func HeaderFromAPIGWProxyHeader ¶
func HeaderFromAPIGWProxyHeader(ph APIGWProxyHeader) *Header
HeaderFromAPIGWProxyHeader creates new Header from APIGWProxyHeader
func (*Header) ToAPIGWProxyHeader ¶
func (h *Header) ToAPIGWProxyHeader() APIGWProxyHeader
ToAPIGWProxyHeader convert http.Header to LambdaHeader
type LambdaHandler ¶
type LambdaHandler func(context.Context, *events.APIGatewayProxyRequest) (*events.APIGatewayProxyResponse, error)
LambdaHandler func type for lambda.Start()
func CreateLambdaHandler ¶
func CreateLambdaHandler(conf *Configuration, h http.Handler) LambdaHandler
CreateLambdaHandler create lambda handler
type LambdaHandlerV2 ¶ added in v0.2.0
type LambdaHandlerV2 func(context.Context, *events.APIGatewayV2HTTPRequest) (*events.APIGatewayProxyResponse, error)
LambdaHandlerV2 func type for lambda.Start()
func CreateLambdaHandlerV2 ¶ added in v0.2.0
func CreateLambdaHandlerV2(conf *Configuration, h http.Handler) LambdaHandlerV2
CreateLambdaHandlerV2 create lambda handler
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
ResponseWriter implements http.ResponseWriter used for buffering response
func NewResponseWriter ¶
func NewResponseWriter() *ResponseWriter
NewResponseWriter creates new empty ResponseWriter
func (*ResponseWriter) Header ¶
func (r *ResponseWriter) Header() http.Header
Header returns http.Header. You can modify it to send response header
func (*ResponseWriter) ToAPIGWProxyResponse ¶
func (r *ResponseWriter) ToAPIGWProxyResponse() *events.APIGatewayProxyResponse
ToAPIGWProxyResponse convert it to events.APIGatewayProxyResponse
func (*ResponseWriter) Write ¶
func (r *ResponseWriter) Write(chunk []byte) (int, error)
Write appends chunk to response body
func (*ResponseWriter) WriteHeader ¶
func (r *ResponseWriter) WriteHeader(statusCode int)
WriteHeader set status code of current request