From c9ba660e7f8b3268d0a1ad9d37054524fd3d5436 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Thu, 7 Nov 2013 22:05:20 -0800 Subject: [PATCH] added server info for the / route --- control.go | 14 ++++++++++++++ main.go | 1 + 2 files changed, 15 insertions(+) diff --git a/control.go b/control.go index 766a95e..e0123b3 100644 --- a/control.go +++ b/control.go @@ -126,3 +126,17 @@ func killServer(w http.ResponseWriter, req *http.Request) { } log.Fatal("shit got fucked up") } + +func index(w http.ResponseWriter, req *http.Request) { + log.Println("version requested") + version := struct { + Version string `json:"version"` + Name string `json:"name"` + }{ + Version: "0.1.2", + Name: "Hackerbots", + } + if err := json.NewEncoder(w).Encode(version); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } +} diff --git a/main.go b/main.go index d7bebd3..e600dc6 100644 --- a/main.go +++ b/main.go @@ -55,6 +55,7 @@ func main() { sm := http.NewServeMux() + sm.Handle("/", JsonHandler(index)) sm.Handle("/ws/", websocket.Handler(addPlayer)) sm.Handle("/game/start/", JsonHandler(startGame)) sm.Handle("/game/list/", JsonHandler(listGames))