24 lines
452 B
Go
24 lines
452 B
Go
package handler
|
|
|
|
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)
|
|
|
|
if transformError(c, err) {
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, rest.Status{
|
|
Turn: g.Turn,
|
|
Players: len(g.Race),
|
|
})
|
|
}
|