added server info for the / route
This commit is contained in:
parent
caea45741f
commit
c9ba660e7f
14
control.go
14
control.go
@ -126,3 +126,17 @@ func killServer(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
log.Fatal("shit got fucked up")
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1
main.go
1
main.go
@ -55,6 +55,7 @@ func main() {
|
|||||||
|
|
||||||
sm := http.NewServeMux()
|
sm := http.NewServeMux()
|
||||||
|
|
||||||
|
sm.Handle("/", JsonHandler(index))
|
||||||
sm.Handle("/ws/", websocket.Handler(addPlayer))
|
sm.Handle("/ws/", websocket.Handler(addPlayer))
|
||||||
sm.Handle("/game/start/", JsonHandler(startGame))
|
sm.Handle("/game/start/", JsonHandler(startGame))
|
||||||
sm.Handle("/game/list/", JsonHandler(listGames))
|
sm.Handle("/game/list/", JsonHandler(listGames))
|
||||||
|
Loading…
Reference in New Issue
Block a user