{"modulePath":"github.com/Foodji/aws-lambda-go","version":"v1.20.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package lambda\n\n## Variables\n\n```go\nvar LambdaShutdownRequest error = errors.New(\"Lambda Shutdown Request\")\n```\n\n## Functions\n\n```go\nfunc Start(handler interface{})\n```\nStart takes a handler and talks to an internal Lambda endpoint to pass requests to the handler. If the handler does not match one of the supported types an appropriate error message will be returned to the caller. Start blocks, and does not return after being called.\n\nRules:\n\n  - handler must be a function\n  - handler may take between 0 and two arguments.\n  - if there are two arguments, the first argument must satisfy the \"context.Context\" interface.\n  - handler may return between 0 and two arguments.\n  - if there are two return values, the second argument must be an error.\n  - if there is one return value it must be an error.\n\nValid function signatures:\n\n\tfunc ()\n\tfunc () error\n\tfunc (TIn) error\n\tfunc () (TOut, error)\n\tfunc (TIn) (TOut, error)\n\tfunc (context.Context) error\n\tfunc (context.Context, TIn) error\n\tfunc (context.Context) (TOut, error)\n\tfunc (context.Context, TIn) (TOut, error)\n\nWhere \"TIn\" and \"TOut\" are types compatible with the \"encoding/json\" standard library. See [https://golang.org/pkg/encoding/json/#Unmarshal](https://golang.org/pkg/encoding/json/#Unmarshal) for how deserialization behaves\n\n```go\nfunc StartHandler(handler Handler)\n```\nStartHandler takes in a Handler wrapper interface which can be implemented either by a custom function or a struct.\n\nHandler implementation requires a single \"Invoke()\" function:\n\n\tfunc Invoke(context.Context, []byte) ([]byte, error)\n\n```go\nfunc StartHandlerWithContext(ctx context.Context, handler Handler)\n```\nStartHandlerWithContext is the same as StartHandler except sets the base context for the function.\n\nHandler implementation requires a single \"Invoke()\" function:\n\n\tfunc Invoke(context.Context, []byte) ([]byte, error)\n\n```go\nfunc StartWithContext(ctx context.Context, handler interface{})\n```\nStartWithContext is the same as Start except sets the base context for the function.\n\n## Types\n\n```go\ntype Function struct {\n\t// contains filtered or unexported fields\n}\n```\nFunction struct which wrap the Handler\n\n```go\nfunc NewFunction(handler Handler) *Function\n```\nNewFunction which creates a Function with a given Handler\n\n```go\nfunc (fn *Function) Invoke(req *messages.InvokeRequest, response *messages.InvokeResponse) error\n```\nInvoke method try to perform a command given an InvokeRequest and an InvokeResponse\n\n```go\nfunc (fn *Function) Ping(req *messages.PingRequest, response *messages.PingResponse) error\n```\nPing method which given a PingRequest and a PingResponse parses the PingResponse\n\n```go\ntype Handler interface {\n\tInvoke(ctx context.Context, payload []byte) ([]byte, error)\n}\n```\n\n```go\nfunc NewHandler(handlerFunc interface{}) Handler\n```\nNewHandler creates a base lambda handler from the given handler function. The returned Handler performs JSON deserialization and deserialization, and delegates to the input handler function.  The handler function parameter must satisfy the rules documented by Start.  If handlerFunc is not a valid handler, the returned Handler simply reports the validation error.\n\n","path":"github.com/Foodji/aws-lambda-go/lambda","name":"lambda","synopsis":"","isRedistributable":true}
