28 lines
475 B
Go
28 lines
475 B
Go
|
package controller
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/labstack/echo/v4"
|
||
|
"gitrepo.ru/neonxp/nquest/pkg/models"
|
||
|
"gitrepo.ru/neonxp/nquest/pkg/service"
|
||
|
)
|
||
|
|
||
|
type Game struct {
|
||
|
GameService *service.Game
|
||
|
}
|
||
|
|
||
|
func (index *Game) Index(c echo.Context) error {
|
||
|
|
||
|
games, err := index.GameService.List(c.Request().Context())
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return c.Render(http.StatusOK, "index", &GamesResponse{Games: games})
|
||
|
}
|
||
|
|
||
|
type GamesResponse struct {
|
||
|
Games []*models.Game
|
||
|
}
|