We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1285854 commit d2c7a40Copy full SHA for d2c7a40
docker-cloud/main.go
@@ -4,20 +4,26 @@ import (
4
"fmt"
5
"log"
6
"net/http"
7
+ "os"
8
)
9
10
type Config struct {
- Port int
11
+ Port string
12
}
13
14
func main() {
15
+ port := os.Getenv("HTTP_PORT")
16
+ if port == "" {
17
+ port = "8080"
18
+ }
19
+
20
config := Config{
- Port: 8080,
21
+ Port: port,
22
23
24
http.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
25
w.Write([]byte("pong"))
26
})
27
- log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", config.Port), nil))
28
+ log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", config.Port), nil))
29
0 commit comments