]>
Commit | Line | Data |
---|---|---|
1 | diff --git a/cmd/greenapid/main.go b/cmd/greenapid/main.go | |
2 | index 86499e9..1589323 100644 | |
3 | --- a/cmd/greenapid/main.go | |
4 | +++ b/cmd/greenapid/main.go | |
5 | @@ -1,6 +1,7 @@ | |
6 | package main | |
7 | ||
8 | import ( | |
9 | + "net" | |
10 | "net/http" | |
11 | ||
12 | "github.com/jbowens/codenamesgreen/gameapi" | |
13 | @@ -13,6 +14,12 @@ func main() { | |
14 | } | |
15 | ||
16 | h := gameapi.Handler(wordLists) | |
17 | - err = http.ListenAndServe(":8080", h) | |
18 | + server := &http.Server{Handler: h} | |
19 | + ln, err := net.Listen("unix", "/run/codenamesgreen/socket.sock") | |
20 | + if err != nil { | |
21 | + panic(err) | |
22 | + } | |
23 | + | |
24 | + err = server.Serve(ln) | |
25 | panic(err) | |
26 | } | |
27 | diff --git a/gameapi/handler.go b/gameapi/handler.go | |
28 | index d67cf94..108e7e1 100644 | |
29 | --- a/gameapi/handler.go | |
30 | +++ b/gameapi/handler.go | |
31 | @@ -101,7 +101,7 @@ func (h *handler) handleIndex(rw http.ResponseWriter, req *http.Request) { | |
32 | for { | |
33 | w1 := strings.ToLower(h.allWords[h.rand.Int63n(int64(len(h.allWords)))]) | |
34 | w2 := strings.ToLower(h.allWords[h.rand.Int63n(int64(len(h.allWords)))]) | |
35 | - id := fmt.Sprintf("%s-%s", w1, w2) | |
36 | + id = fmt.Sprintf("%s-%s", w1, w2) | |
37 | if _, ok := h.games[id]; !ok { | |
38 | break | |
39 | } |