From 7eb0144485ff5698e9bf1789b7a932ee2a715b78 Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Fri, 3 Nov 2023 14:49:40 -0400 Subject: [PATCH] Allow specifying listen addr --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 694114a..726ea83 100644 --- a/main.go +++ b/main.go @@ -37,8 +37,13 @@ func init() { func main() { http.HandleFunc("/proxyUrl", checkUrl) - log.Println("Server listening on :8080") - if err := http.ListenAndServe(":8080", nil); err != nil { + listen := os.Getenv("LISTEN") + if listen == "" { + listen = "127.0.0.1:8888" + } + + log.Printf("Server listening on %s\n", listen) + if err := http.ListenAndServe(listen, nil); err != nil { panic(err) } }