|
@@ -7,6 +7,7 @@ import (
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
"log"
|
|
"log"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
|
|
+ "runtime/pprof"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
"github.com/julienschmidt/httprouter"
|
|
@@ -27,6 +28,7 @@ func newUrlRouter(gs *GameServer) *httprouter.Router {
|
|
|
router.GET("/games/:gameid/:boardid", proxyHandler)
|
|
router.GET("/games/:gameid/:boardid", proxyHandler)
|
|
|
router.GET("/games/:gameid/:boardid/:playerid", showPlayer)
|
|
router.GET("/games/:gameid/:boardid/:playerid", showPlayer)
|
|
|
router.POST("/games/:gameid/move/:playerid/:direction", movePlayer)
|
|
router.POST("/games/:gameid/move/:playerid/:direction", movePlayer)
|
|
|
|
|
+ router.GET("/debug/profiledump", profileDump)
|
|
|
|
|
|
|
|
return router
|
|
return router
|
|
|
}
|
|
}
|
|
@@ -169,3 +171,7 @@ func showAsciiBoard(w http.ResponseWriter, req *http.Request, ps httprouter.Para
|
|
|
b := gameServer.GetGame(id).Board.String()
|
|
b := gameServer.GetGame(id).Board.String()
|
|
|
w.Write([]byte(b))
|
|
w.Write([]byte(b))
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func profileDump(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
|
|
|
|
+ pprof.StopCPUProfile()
|
|
|
|
|
+}
|