feat: status api
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user