refactor: executors and routers
* refactor: executors and routers
This commit is contained in:
@@ -4,20 +4,14 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/internal/game"
|
||||
"github.com/iliadenisov/galaxy/internal/model/rest"
|
||||
)
|
||||
|
||||
func StatusHandler(c *gin.Context, config controller.Configurer) {
|
||||
g, err := game.LoadState(config)
|
||||
func StatusHandler(c *gin.Context, executor CommandExecutor) {
|
||||
state, err := executor.GameState()
|
||||
|
||||
if transformError(c, err) {
|
||||
if errorResponded(c, err) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, rest.Status{
|
||||
Turn: g.Turn,
|
||||
Players: len(g.Race),
|
||||
})
|
||||
c.JSON(http.StatusOK, state)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user