in lambda/rapidcore/standalone/initHandler.go [59:104]
func InitHandler(w http.ResponseWriter, r *http.Request, sandbox InteropServer, bs interop.Bootstrap) {
init := InitBody{}
if lerr := readBodyAndUnmarshalJSON(r, &init); lerr != nil {
lerr.Send(w, r)
return
}
if err := init.Validate(); err != nil {
newErrorReply(ClientInvalidRequest, err.Error()).Send(w, r)
return
}
for envKey, envVal := range init.Customer.Environment {
// We set environment variables to keep the env parsing & filtering
// logic consistent across standalone-mode and girp-mode
os.Setenv(envKey, envVal)
}
awsKey, awsSecret, awsSession := getCredentials(init)
sandboxType := interop.SandboxClassic
if init.Throttled {
sandboxType = interop.SandboxPreWarmed
}
// pass to rapid
sandbox.Init(&interop.Init{
Handler: init.Handler,
AwsKey: awsKey,
AwsSecret: awsSecret,
AwsSession: awsSession,
CredentialsExpiry: init.CredentialsExpiry,
XRayDaemonAddress: "0.0.0.0:0", // TODO
FunctionName: init.FunctionName,
FunctionVersion: init.FunctionVersion,
RuntimeInfo: interop.RuntimeInfo{
ImageJSON: init.RuntimeInfo.ImageJSON,
Arn: init.RuntimeInfo.Arn,
Version: init.RuntimeInfo.Version},
CustomerEnvironmentVariables: env.CustomerEnvironmentVariables(),
SandboxType: sandboxType,
Bootstrap: bs,
EnvironmentVariables: env.NewEnvironment(),
}, init.InvokeTimeoutMs)
}