Skip to content

Commit 9f2eee1

Browse files
committed
Merge branch '29-golang-1.12' into 'master'
Rewrite main func for go111 runtime Closes #29 See merge request tnir/docs.djangoproject.jp!24
2 parents 6e23377 + e401551 commit 9f2eee1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

redirect.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package main
22

33
import (
4+
"fmt"
5+
"log"
46
"net/http"
7+
"os"
58
"regexp"
69
"strings"
710
)
@@ -75,4 +78,13 @@ func redirect(w http.ResponseWriter, r *http.Request) {
7578

7679
func main() {
7780
http.HandleFunc("/", redirect)
81+
82+
port := os.Getenv("PORT")
83+
if port == "" {
84+
port = "8080"
85+
log.Printf("Defaulting to port %s", port)
86+
}
87+
88+
log.Printf("Listening on port %s", port)
89+
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
7890
}

0 commit comments

Comments
 (0)