Read HTTP port from the environment
@@ -121,5 +121,10 @@ func main() {
srv.Start()
http.HandleFunc("/", handleRequest)
- log.Fatal(http.ListenAndServe(":8080", nil))
+
+ port := os.Getenv("PORT")
+ if port == "" {
+ port = "8080"
+ }
+ log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
}
