feat: status api

This commit is contained in:
Ilia Denisov
2026-01-07 18:38:06 +02:00
parent 1b0ab7a079
commit 204d3df8cf
20 changed files with 188 additions and 40 deletions
+3 -7
View File
@@ -7,7 +7,6 @@ import (
"github.com/iliadenisov/galaxy/internal/game"
"github.com/gin-gonic/gin"
"github.com/iliadenisov/galaxy/internal/controller"
"github.com/iliadenisov/galaxy/internal/model/rest"
)
@@ -26,18 +25,15 @@ func CommandHandler(c *gin.Context, executor Executor) {
case err == nil:
c.Status(http.StatusOK)
case errors.Is(err, ErrCommandNotProcessed):
c.Status(http.StatusInternalServerError)
c.Status(http.StatusInternalServerError) // TODO: add error text?
default:
// TODO: separate bad value errors and game state errors
// TODO: separate invalid input and game state errors
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
}
}
func Execute(cmd rest.Command) error {
p := func(p *controller.Param) {
// TODO: initialize base controller settings
p.StoragePath = ""
}
p := param()
switch {
case cmd.DeclareWar != nil:
return game.DeclareWar(p, cmd.Race, cmd.DeclareWar.Opponent)