| 12345678910111213141516171819202122232425 |
- package main
- import (
- "net/http"
- "github.com/julienschmidt/httprouter"
- )
- func initRouter() *httprouter.Router {
- router := httprouter.New()
- router.GET("/", showIndex)
- router.GET("/games", listGames)
- router.PUT("/games", createGame)
- router.PUT("/games/:rows/:cols", createGame)
- router.GET("/games/:gameid", showGame)
- router.GET("/games/:gameid/:boardid", proxyHandler)
- //router.GET("/games/:gameid/players", playerListHandler)
- // TODO: /games/{id}/players/{playerId}
- router.POST("/games/:gameid/move/:playerId/:direction", movePlayer)
- router.PanicHandler = func(w http.ResponseWriter, r *http.Request, something interface{}) {
- http.Error(w, "Internal server error", http.StatusInternalServerError)
- }
- return router
- }
|