refactor: executors and routers

* refactor: executors and routers
This commit is contained in:
Ilia Denisov
2026-02-09 15:53:34 +03:00
committed by GitHub
parent e48a0c8b96
commit d9c8de27e5
38 changed files with 508 additions and 838 deletions
+4 -8
View File
@@ -4,15 +4,12 @@ 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 InitHandler(c *gin.Context, config controller.Configurer) {
func InitHandler(c *gin.Context, executor CommandExecutor) {
var init rest.Init
if err := c.ShouldBindJSON(&init); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
if errorResponded(c, c.ShouldBindJSON(&init)) {
return
}
@@ -21,10 +18,9 @@ func InitHandler(c *gin.Context, config controller.Configurer) {
races[i] = init.Races[i].Name
}
uuid, err := game.GenerateGame(config, races)
if transformError(c, err) {
uuid, err := executor.GenerateGame(races)
if errorResponded(c, err) {
return
}
c.JSON(http.StatusCreated, rest.InitResponse{