Documentation
¶
Index ¶
- type LambdaMiddleware
- func (*LambdaMiddleware) CaddyModule() caddy.ModuleInfo
- func (m *LambdaMiddleware) Cleanup() error
- func (m *LambdaMiddleware) Provision(ctx caddy.Context) error
- func (m *LambdaMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (m *LambdaMiddleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (m *LambdaMiddleware) Validate() error
- type Reply
- type ReplyMeta
- type Request
- type RequestMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LambdaMiddleware ¶
type LambdaMiddleware struct {
FunctionName string `json:"function,omitempty"`
Timeout string `json:"timeout,omitempty"`
// contains filtered or unexported fields
}
LambdaMiddleware implements an HTTP handler that invokes a lambda function
func (*LambdaMiddleware) CaddyModule ¶
func (*LambdaMiddleware) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*LambdaMiddleware) Cleanup ¶
func (m *LambdaMiddleware) Cleanup() error
Cleanup implements caddy.Cleanup TODO: ensure all running processes are terminated.
func (*LambdaMiddleware) Provision ¶
func (m *LambdaMiddleware) Provision(ctx caddy.Context) error
Provision implements caddy.Provisioner.
func (*LambdaMiddleware) ServeHTTP ¶
func (m *LambdaMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
ServeHTTP implements caddyhttp.MiddlewareHandler.
func (*LambdaMiddleware) UnmarshalCaddyfile ¶
func (m *LambdaMiddleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile configures the global directive from Caddyfile. Syntax:
awslambda [<matcher>] {
function <function name>
timeout <duration>
}
func (*LambdaMiddleware) Validate ¶
func (m *LambdaMiddleware) Validate() error
Validate implements caddy.Validator
type Reply ¶
type Reply struct {
// Must be set to the constant "HTTPJSON-REP"
Type string `json:"type"`
// Reply metadata. If omitted, a default 200 status with empty headers will be used.
Meta *ReplyMeta `json:"meta"`
// Response body
Body string `json:"body"`
// Encoding of Body - Valid values: "", "base64"
BodyEncoding string `json:"bodyEncoding"`
}
Reply encapsulates the response from a Lambda invocation. AWS Lambda functions should return a JSON object that matches this format.
type ReplyMeta ¶
type ReplyMeta struct {
// HTTP status code (e.g. 200 or 404)
Status int `json:"status"`
// HTTP response headers
Headers map[string][]string `json:"headers"`
}
ReplyMeta encapsulates HTTP response metadata that the lambda function wishes Caddy to set on the HTTP response.
*NOTE* that header values must be encoded as string arrays
type Request ¶
type Request struct {
// Set to the constant "HTTPJSON-REQ"
Type string `json:"type"`
// Metadata about the HTTP request
Meta *RequestMeta `json:"meta"`
// HTTP request body (may be empty)
Body string `json:"body"`
}
Request represents a single HTTP request. It will be serialized as JSON and sent to the AWS Lambda function as the function payload.
type RequestMeta ¶
type RequestMeta struct {
// HTTP method used by client (e.g. GET or POST)
Method string `json:"method"`
// Path portion of URL without the query string
Path string `json:"path"`
// Query string (without '?')
Query string `json:"query"`
// Host field from net/http Request, which may be of the form host:port
Host string `json:"host"`
// Proto field from net/http Request, for example "HTTP/1.1"
Proto string `json:"proto"`
// HTTP request headers
Headers map[string][]string `json:"headers"`
}
RequestMeta represents HTTP metadata present on the request