We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent db462a8 commit cf32accCopy full SHA for cf32acc
main.go
@@ -8,6 +8,7 @@ import (
8
"io/ioutil"
9
"log"
10
"net/http"
11
+ "os"
12
"strings"
13
14
"github.com/gorilla/mux"
@@ -128,10 +129,15 @@ func main() {
128
129
return nil
130
})
131
132
+ port := os.Getenv("PORT")
133
+ if port == "" {
134
+ port = "8093"
135
+ }
136
+
137
r := mux.NewRouter()
138
r.HandleFunc("/isbn/{isbn}", IsbnAPI)
- fmt.Println("server running on http://localhost:8093/isbn/{$ISBN}")
139
+ fmt.Printf("server running on http://localhost:%s/isbn/{$ISBN}", port)
140
- http.ListenAndServe(":8093", r)
141
+ http.ListenAndServe(fmt.Sprintf(":%s", port), r)
142
143
}
0 commit comments