Made info url more useful (start and uptime)

This commit is contained in:
sm
2015-08-26 22:25:38 -07:00
parent b5cac7c02a
commit 5cac75b638
2 changed files with 34 additions and 18 deletions
+2 -18
View File
@@ -54,7 +54,7 @@ func NewController(conf Config, mprof, pprof string) *http.ServeMux {
go c.Run()
sm := http.NewServeMux()
sm.Handle("/", JsonHandler(c.Index))
sm.Handle("/", JsonHandler(c.Info))
sm.Handle("/ws/", websocket.Handler(c.AddPlayer))
sm.Handle("/api/v0/game/start/", JsonHandler(c.StartGame))
sm.Handle("/api/v0/game/list/", JsonHandler(c.ListGames))
@@ -62,6 +62,7 @@ func NewController(conf Config, mprof, pprof string) *http.ServeMux {
sm.Handle("/api/v0/game/bw/", JsonHandler(c.BW))
sm.Handle("/api/v0/game/stop/", JsonHandler(c.StopGame))
sm.HandleFunc("/api/v0/fsu/", c.KillServer)
sm.HandleFunc("/api/v0/info/", c.Info)
return sm
}
@@ -307,23 +308,6 @@ func (c *Controller) KillServer(w http.ResponseWriter, req *http.Request) {
log.Fatal("shit got fucked up")
}
// Index is the function for handling all traffic not officially in the API. It
// just lets people know that this is a hackerbots server running at
// a particular version.
func (c *Controller) 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)
}
}
// getGameId trims the gameid off of the url. This is hokey, and makes me miss
// django regex-specified routes.
func (c *Controller) getGameId(path string) (string, error) {