Skip to content

Commit e178e32

Browse files
committed
It was difficult to use rootHandler in the test, so stopped making it a global variable
1 parent cb40cdd commit e178e32

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ var port = getEnv("PORT", "8080")
1919
var rieEndpoint = getEnv("RIE_ENDPOINT", "http://localhost:9000/2015-03-31/functions/function/invocations")
2020
var enableCors = getEnv("ENABLE_CORS", "false")
2121

22-
// It is a global variable for testing.
23-
var rootHandler http.Handler
24-
2522
func getEnv(key, fallback string) string {
2623
if value, exists := os.LookupEnv(key); exists {
2724
return value
@@ -30,12 +27,15 @@ func getEnv(key, fallback string) string {
3027
}
3128

3229
func main() {
30+
var rootHandler http.Handler
31+
3332
if enableCors == "true" {
3433
rootHandler = cors.AllowAll().Handler(http.HandlerFunc(lambdaUrlProxyHandler))
3534
log.Println("[Lambda URL Proxy] CORS enabled")
3635
} else {
3736
rootHandler = http.HandlerFunc(lambdaUrlProxyHandler)
3837
}
38+
3939
http.Handle("/", rootHandler)
4040
log.Printf("[Lambda URL Proxy] Listening on http://localhost:%s\n", port)
4141
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))

0 commit comments

Comments
 (0)