-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
32 lines (26 loc) · 957 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"os"
"github.com/arllanos/minesweeper-API/controller"
router "github.com/arllanos/minesweeper-API/http"
"github.com/arllanos/minesweeper-API/repository"
"github.com/arllanos/minesweeper-API/services"
)
const defaultPort = "8080"
var (
gameRepository repository.GameRepository = repository.NewRedisRepository()
gameService services.GameService = services.NewGameService(gameRepository)
httpRouter router.Router = router.NewChiRouter()
gameController controller.GameController = controller.NewGameController(gameService)
)
func main() {
httpRouter.POST("/users", gameController.CreateUser)
httpRouter.PUT("/games", gameController.CreateGame)
httpRouter.POST("/games/{gamename}/{username}/click", gameController.ClickCell)
httpRouter.GET("/games/{gamename}/{username}/board", gameController.GetBoard)
port := os.Getenv("PORT")
if port == "" {
port = defaultPort
}
httpRouter.SERVE(port)
}