{"modulePath":"github.com/aws/aws-lambda-go","version":"v1.55.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package lambda\n\nPackage lambda provides the runtime interface for AWS Lambda functions written in Go.\n\nThis package handles communication with the Lambda execution environment, including receiving invocation events, managing context, and returning responses.\n\nUse lambda.Start() to register your handler function and begin processing Lambda invocations.\n\nSee [https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html](https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html)\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 values.\n  - if there are two return values, the second return value 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 (TIn)\n\tfunc () error\n\tfunc (TIn) error\n\tfunc () (TOut, error)\n\tfunc (TIn) (TOut, error)\n\tfunc (context.Context)\n\tfunc (context.Context) error\n\tfunc (context.Context) (TOut, error)\n\tfunc (context.Context, TIn)\n\tfunc (context.Context, TIn) 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\"TOut\" may also implement io.Reader to return raw response data (e.g., HTML, XML, binary). If the response also implements io.Closer, Close() will be called after sending. Errors from Read() (other than io.EOF) are reported as function errors.\n\nNote: If \"TOut\" is both JSON serializable and implements io.Reader, JSON serialization takes precedence.\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\nDeprecated: use lambda.Start(handler) instead\n\n```go\nfunc StartHandlerFunc[TIn any, TOut any, H HandlerFunc[TIn, TOut]](handler H, options ...Option)\n```\nStartHandlerFunc is the same as StartWithOptions except that it takes a generic input so that the function signature can be validated at compile time.\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\nDeprecated: use lambda.StartWithOptions(handler, lambda.WithContext(ctx)) instead\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\nDeprecated: use lambda.StartWithOptions(handler, lambda.WithContext(ctx)) instead\n\n```go\nfunc StartWithOptions(handler interface{}, options ...Option)\n```\nStartWithOptions is the same as Start after the application of any handler options specified\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\nDeprecated: The Function type is public for the go1.x runtime internal use of the net/rpc package\n\n```go\nfunc NewFunction(handler Handler) *Function\n```\nNewFunction which creates a Function with a given Handler\n\nDeprecated: The Function type is public for the go1.x runtime internal use of the net/rpc package\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 serialization 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```go\nfunc NewHandlerWithOptions(handlerFunc interface{}, options ...Option) Handler\n```\nNewHandlerWithOptions creates a base lambda handler from the given handler function. The returned Handler performs JSON serialization 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```go\ntype HandlerFunc[TIn, TOut any] interface {\n\tfunc(context.Context, TIn) (TOut, error)\n}\n```\nHandlerFunc represents a valid input with two arguments and two returns as described by Start\n\n```go\ntype Option func(*handlerOptions)\n```\n\n```go\nfunc WithContext(ctx context.Context) Option\n```\nWithContext is a HandlerOption that sets the base context for all invocations of the handler.\n\n```go\nfunc WithContextValue(key interface{}, value interface{}) Option\n```\nWithContextValue adds a value to the handler context. If a base context was set using WithContext, that base is used as the parent.\n\n```go\nfunc WithDisallowUnknownFields(disallowUnknownFields bool) Option\n```\nWithDisallowUnknownFields sets the DisallowUnknownFields option on the underlying json decoder\n\n```go\nfunc WithEnableSIGTERM(callbacks ...func()) Option\n```\nWithEnableSIGTERM enables SIGTERM behavior within the Lambda platform on container spindown. SIGKILL will occur ~500ms after SIGTERM. Optionally, an array of callback functions to run on SIGTERM may be provided.\n\n```go\nfunc WithSetEscapeHTML(escapeHTML bool) Option\n```\nWithSetEscapeHTML sets the SetEscapeHTML argument on the underlying json encoder\n\n```go\nfunc WithSetIndent(prefix, indent string) Option\n```\nWithSetIndent sets the SetIndent argument on the underling json encoder\n\n```go\nfunc WithUseNumber(useNumber bool) Option\n```\nWithUseNumber sets the UseNumber option on the underlying json decoder\n\n","path":"github.com/aws/aws-lambda-go/lambda","name":"lambda","synopsis":"Package lambda provides the runtime interface for AWS Lambda functions written in Go.","isRedistributable":true}
