added more logging to control requests

This commit is contained in:
Stephen McQuay 2013-10-14 00:17:12 -07:00
parent 158c7d90d8
commit f4e2e84676

View File

@ -16,6 +16,7 @@ func (h JsonHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
func startGame(w http.ResponseWriter, req *http.Request) { func startGame(w http.ResponseWriter, req *http.Request) {
log.Println("asked to create a game")
new_game_name := idg.Hash() new_game_name := idg.Hash()
_g := NewGame(new_game_name, *width, *height) _g := NewGame(new_game_name, *width, *height)
@ -36,6 +37,7 @@ func startGame(w http.ResponseWriter, req *http.Request) {
} }
func listGames(w http.ResponseWriter, req *http.Request) { func listGames(w http.ResponseWriter, req *http.Request) {
log.Println("games list requested")
games.RLock() games.RLock()
defer games.RUnlock() defer games.RUnlock()
type pout struct { type pout struct {
@ -68,6 +70,7 @@ func listGames(w http.ResponseWriter, req *http.Request) {
func stopGame(w http.ResponseWriter, req *http.Request) { func stopGame(w http.ResponseWriter, req *http.Request) {
trimmed := strings.Trim(req.URL.Path, "/") trimmed := strings.Trim(req.URL.Path, "/")
fullPath := strings.Split(trimmed, "/") fullPath := strings.Split(trimmed, "/")
log.Println(req.URL.Path)
if len(fullPath) != 3 { if len(fullPath) != 3 {
http.Error(w, "improperly formed url", http.StatusBadRequest) http.Error(w, "improperly formed url", http.StatusBadRequest)
return return