-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (33 loc) · 754 Bytes
/
Copy pathmain.go
File metadata and controls
39 lines (33 loc) · 754 Bytes
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
36
37
38
39
package main
import (
"log"
"net/http"
"os"
"github.com/gocs/map/static"
"github.com/gocs/map/ws"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "80"
}
mapOrigin := os.Getenv("GOCS_MAP_ORIGIN")
if mapOrigin == "" {
mapOrigin = "http://localhost:" + port
}
a, err := static.Assets()
if err != nil {
log.Fatalln("assets err:", err)
return
}
http.Handle("/", a)
http.HandleFunc("/land.json", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "land.json")
})
http.HandleFunc("/updaterws", ws.UpdaterWS(mapOrigin))
http.HandleFunc("/ws", ws.UpdaterWS(mapOrigin))
log.Printf("Listening on :%s...\n", port)
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Fatal(err)
}
}