{"modulePath":"github.com/aws/aws-lambda-runtime-interface-emulator","version":"v0.0.0-20261030222936-bef5c4ba774d","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package appctx\n\n## Constants\n\n```go\nconst MaxRuntimeReleaseLength = 128\n```\nMaxRuntimeReleaseLength Max length for user agent string.\n\n## Functions\n\n```go\nfunc CreateRuntimeReleaseFromRequest(request *http.Request, runtimeRelease string) string\n```\nCreateRuntimeReleaseFromRequest Gets runtime features from request header 'Lambda-Runtime-Features', and append it to the given runtime release.\n\n```go\nfunc GetRuntimeRelease(appCtx ApplicationContext) string\n```\nGetRuntimeRelease returns runtime\\_release str extracted from app context.\n\n```go\nfunc GetUserAgentFromRequest(request *http.Request) string\n```\nGetUserAgentFromRequest Returns the first token -seperated by a space- from request header 'User-Agent'.\n\n```go\nfunc LoadFirstFatalError(appCtx ApplicationContext) (errorType fatalerror.ErrorType, found bool)\n```\nLoadFirstFatalError returns stored error if found\n\n```go\nfunc LoadInteropServer(appCtx ApplicationContext) interop.Server\n```\nLoadInteropServer retrieves the interop server.\n\n```go\nfunc LoadInvokeErrorTraceData(appCtx ApplicationContext) *interop.InvokeErrorTraceData\n```\nLoadInvokeErrorTraceData retrieves invocation error x-ray cause header from the application context.\n\n```go\nfunc LoadResponseSender(appCtx ApplicationContext) interop.InvokeResponseSender\n```\nLoadResponseSender retrieves the response sender\n\n```go\nfunc LoadSandboxType(appCtx ApplicationContext) interop.SandboxType\n```\n\n```go\nfunc RequestWithAppCtx(request *http.Request, appCtx ApplicationContext) *http.Request\n```\nRequestWithAppCtx places application context into request context.\n\n```go\nfunc StoreFirstFatalError(appCtx ApplicationContext, err fatalerror.ErrorType)\n```\nStoreFirstFatalError stores unrecoverable error code in appctx once. This error is considered to be the rootcause of failure\n\n```go\nfunc StoreInitType(appCtx ApplicationContext, initCachingEnabled bool)\n```\n\n```go\nfunc StoreInteropServer(appCtx ApplicationContext, server interop.Server)\n```\nStoreInteropServer stores a reference to the interop server.\n\n```go\nfunc StoreInvokeErrorTraceData(appCtx ApplicationContext, invokeError *interop.InvokeErrorTraceData)\n```\nStoreInvokeErrorTraceData stores invocation error x-ray cause header in the applicaton context.\n\n```go\nfunc StoreResponseSender(appCtx ApplicationContext, server interop.InvokeResponseSender)\n```\nStoreResponseSender stores a reference to the response sender\n\n```go\nfunc StoreSandboxType(appCtx ApplicationContext, sandboxType interop.SandboxType)\n```\n\n```go\nfunc UpdateAppCtxWithRuntimeRelease(request *http.Request, appCtx ApplicationContext) bool\n```\nUpdateAppCtxWithRuntimeRelease extracts runtime release info from user agent \u0026 lambda runtime features headers and update it into appCtx. Sample UA: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0\n\n## Types\n\n```go\ntype ApplicationContext interface {\n\tStore(key Key, value interface{})\n\tLoad(key Key) (value interface{}, ok bool)\n\tDelete(key Key)\n\tGetOrDefault(key Key, defaultValue interface{}) interface{}\n\tStoreIfNotExists(key Key, value interface{}) interface{}\n}\n```\nApplicationContext is an application scope context.\n\n```go\nfunc FromRequest(request *http.Request) ApplicationContext\n```\nFromRequest retrieves application context from the request context.\n\n```go\nfunc NewApplicationContext() ApplicationContext\n```\nNewApplicationContext returns a new instance of application context.\n\n```go\ntype InitType int\n```\n\n```go\nconst (\n\tInit InitType = iota\n\tInitCaching\n)\n```\nPossible values for AppCtxInitType key\n\n```go\nfunc LoadInitType(appCtx ApplicationContext) InitType\n```\nDefault Init Type is Init unless it's explicitly stored in ApplicationContext\n\n```go\ntype Key int\n```\nA Key type is used as a key for storing values in the application context.\n\n```go\nconst (\n\t// AppCtxInvokeErrorTraceDataKey is used for storing deferred invoke error cause header value.\n\t// Only used by xray. TODO refactor xray interface so it doesn't use appctx\n\tAppCtxInvokeErrorTraceDataKey Key = iota\n\n\t// AppCtxRuntimeReleaseKey is used for storing runtime release information (parsed from User_Agent Http header string).\n\tAppCtxRuntimeReleaseKey\n\n\t// AppCtxInteropServerKey is used to store a reference to the interop server.\n\tAppCtxInteropServerKey\n\n\t// AppCtxResponseSenderKey is used to store a reference to the response sender\n\tAppCtxResponseSenderKey\n\n\t// AppCtxFirstFatalErrorKey is used to store first unrecoverable error message encountered to propagate it to slicer with DONE(errortype) or DONEFAIL(errortype)\n\tAppCtxFirstFatalErrorKey\n\n\t// AppCtxInitType is used to store the init type (init caching or plain INIT)\n\tAppCtxInitType\n\n\t// AppCtxSandbox type is used to store the sandbox type (SandboxClassic or SandboxPreWarmed)\n\tAppCtxSandboxType\n)\n```\n\n```go\ntype ReqCtxKey int\n```\nA ReqCtxKey type is used as a key for storing values in the request context.\n\n```go\nconst ReqCtxApplicationContextKey ReqCtxKey = iota\n```\nReqCtxApplicationContextKey is used for injecting application context object into request context.\n\n","path":"github.com/aws/aws-lambda-runtime-interface-emulator/internal/lambda/appctx","name":"appctx","synopsis":"","isRedistributable":true}
