|
|
@@ -2,37 +2,23 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "battlecamp-go-server/games"
|
|
|
"encoding/json"
|
|
|
"log"
|
|
|
"net/http"
|
|
|
- "runtime"
|
|
|
"strconv"
|
|
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
+
|
|
|
+ "battlecamp-go-server/games"
|
|
|
+ "battlecamp-go-server/stomp"
|
|
|
)
|
|
|
|
|
|
var currentGames games.Games = games.New()
|
|
|
|
|
|
func main() {
|
|
|
- runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
-
|
|
|
- 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)
|
|
|
- }
|
|
|
-
|
|
|
- log.Fatal(http.ListenAndServe(":8080", router))
|
|
|
+ conn := stomp.DailStomp()
|
|
|
+ defer conn.Disconnect()
|
|
|
+ log.Fatal(http.ListenAndServe(":8080", initRouter()))
|
|
|
}
|
|
|
|
|
|
func showIndex(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|