-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.go
35 lines (31 loc) · 812 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"log"
"net/http"
"os"
)
func main() {
if os.Getenv("GAE_ENV") == "standard" {
log.Println("running in App Engine Standard mode")
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
siteMux := http.NewServeMux()
if err := RegisterHandlers(siteMux); err != nil {
log.Fatal(err.Error())
}
http.HandleFunc("/_/fmt", fmtHandler)
http.HandleFunc("/_/compile", runHandler)
http.Handle("/", siteMux)
siteMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/tour/", http.StatusFound)
})
log.Fatal(http.ListenAndServe(":"+port, nil))
return
}
Main()
}