added server info for the / route

This commit is contained in:
Stephen McQuay 2013-11-07 22:05:20 -08:00
parent caea45741f
commit c9ba660e7f
2 changed files with 15 additions and 0 deletions

View File

@ -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)
}
}

View File

@ -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))