feat: init api
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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.Config) {
|
||||
g, err := game.LoadState(config)
|
||||
|
||||
if transformError(c, err) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, rest.Status{
|
||||
Turn: g.Age,
|
||||
Players: len(g.Race),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user