Documentation ¶
Index ¶
- func EarlyTimeout(shutdownTimeMillis int64) func(Handler) Handler
- func ResourceAttribute(ctx context.Context, name string) string
- func ResourceAttributes() func(Handler) Handler
- func RuntimeSession(ctx context.Context) *session.Session
- func WithRuntimeSession() func(Handler) Handler
- type GatewayHandler
- type GatewayRequest
- type GatewayResponse
- type Handler
- type HandlerFunc
- type Invocation
- type Middleware
- type Mux
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EarlyTimeout ¶
EarlyTimeout will cancel the lambda context millisecond before actual timeout to give handlers time to shutdown cleanly
func ResourceAttribute ¶
ResourceAttribute will retrieve a resource attribute from the context or return an empty string if not found
func ResourceAttributes ¶
ResourceAttributes middelware will read a line specific json encoded map from the environment and make it available for reading in handlers
func RuntimeSession ¶
RuntimeSession will return a aws session from the lambda context or panic if it isn't available
func WithRuntimeSession ¶
WithRuntimeSession will include a line specific "runtime" aws.Session into the context that is not based on native lambda credentials
Types ¶
type GatewayHandler ¶
type GatewayHandler struct {
// contains filtered or unexported fields
}
GatewayHandler implements the lambda handler while allowing normal http.Handlers to serve
func NewGatewayHandler ¶
func NewGatewayHandler(stripBasePaths int, httpH http.Handler) *GatewayHandler
NewGatewayHandler makes it easy to serve normal http
func (*GatewayHandler) HandleEvent ¶
func (gwh *GatewayHandler) HandleEvent(ctx context.Context, msg json.RawMessage) (res interface{}, err error)
HandleEvent takes invocations from the API Gateway and turns them into http.Handler invocations
type GatewayRequest ¶
type GatewayRequest struct { HTTPMethod string Headers map[string]string Resource string PathParameters map[string]string Path string QueryStringParameters map[string]string Body string IsBase64Encoded bool StageVariables map[string]string }
GatewayRequest represents an Amazon API Gateway Proxy Event.
type GatewayResponse ¶
type GatewayResponse struct { StatusCode int `json:"statusCode"` Body string `json:"body"` Headers map[string]string `json:"headers"` }
GatewayResponse is returned to the API Gateway
type Handler ¶
type Handler interface {
HandleEvent(ctx context.Context, msg json.RawMessage) (interface{}, error)
}
Handler interface allows any type to handle lambda events
type HandlerFunc ¶
type HandlerFunc func(ctx context.Context, msg json.RawMessage) (interface{}, error)
HandlerFunc is an adaptor that can handle
func (HandlerFunc) HandleEvent ¶
func (h HandlerFunc) HandleEvent(ctx context.Context, msg json.RawMessage) (interface{}, error)
HandleEvent implements Handler
type Invocation ¶
type Invocation struct { FunctionName string `json:"function_name"` FunctionVersion string `json:"function_version"` InvokedFunctionARN string `json:"invoked_function_arn"` MemoryLimitInMB int `json:"memory_limit_in_mb,string"` AWSRequestID string `json:"aws_request_id"` LogGroupName string `json:"log_group_name"` LogStreamName string `json:"log_stream_name"` RemainingTimeInMillis func() int64 `json:"-"` }
Invocation provides additional information about a lambda event
func InvocationFromContext ¶
func InvocationFromContext(ctx context.Context) (*Invocation, bool)
InvocationFromContext returns the original invocation context from a generic context
type Middleware ¶
Middleware allows plugins to manipulate the context and message passed to handlers
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux mutiplexes events to more specific handlers based on regexp matching of a context field
func (*Mux) Handle ¶
func (mux *Mux) Handle(msg json.RawMessage, invoc *Invocation) (interface{}, error)
Handle mill match the invoked function arn to a specific handler