diff --git a/cmd/aws-lambda-rie/http.go b/cmd/aws-lambda-rie/http.go index 88bd39b..5d6ad8b 100644 --- a/cmd/aws-lambda-rie/http.go +++ b/cmd/aws-lambda-rie/http.go @@ -11,15 +11,21 @@ import ( "go.amzn.com/lambda/rapidcore" ) -func startHTTPServer(ipport string, sandbox *rapidcore.SandboxBuilder, bs interop.Bootstrap) { +func startHTTPServer(ipport string, sandbox *rapidcore.SandboxBuilder, bs interop.Bootstrap, funcName string) { srv := &http.Server{ Addr: ipport, } - // Pass a channel - http.HandleFunc("/2015-03-31/functions/function/invocations", func(w http.ResponseWriter, r *http.Request) { - InvokeHandler(w, r, sandbox.LambdaInvokeAPI(), bs) - }) + var functions = []string{funcName} + if funcName != "function" { + functions = []string{"function", funcName} + } + for _, funcName := range functions { + // Pass a channel + http.HandleFunc("/2015-03-31/functions/"+funcName+"/invocations", func(w http.ResponseWriter, r *http.Request) { + InvokeHandler(w, r, sandbox.LambdaInvokeAPI(), bs) + }) + } // go routine (main thread waits) if err := srv.ListenAndServe(); err != nil { diff --git a/cmd/aws-lambda-rie/main.go b/cmd/aws-lambda-rie/main.go index bd15402..7ff7d7f 100644 --- a/cmd/aws-lambda-rie/main.go +++ b/cmd/aws-lambda-rie/main.go @@ -78,13 +78,15 @@ func main() { sandbox.SetRuntimeAPIAddress(opts.RuntimeAPIAddress) } + funcName := GetenvWithDefault("AWS_LAMBDA_FUNCTION_NAME", "function") + sandboxContext, internalStateFn := sandbox.Create() // Since we have not specified a custom interop server for standalone, we can // directly reference the default interop server, which is a concrete type sandbox.DefaultInteropServer().SetSandboxContext(sandboxContext) sandbox.DefaultInteropServer().SetInternalStateGetter(internalStateFn) - startHTTPServer(opts.RuntimeInterfaceEmulatorAddress, sandbox, bootstrap) + startHTTPServer(opts.RuntimeInterfaceEmulatorAddress, sandbox, bootstrap, funcName) } func getCLIArgs() (options, []string) {