Files
games/features/c4game/routes.go
Ryan Hamamura 8536f8e948
All checks were successful
CI / Deploy / test (pull_request) Successful in 16s
CI / Deploy / lint (pull_request) Successful in 25s
CI / Deploy / deploy (pull_request) Has been skipped
refactor: extract GameService for Connect 4 NATS/chat handling
Move NATS subscription and chat room management into a dedicated
GameService, following the portigo service pattern. Handlers now
receive the service and call its methods instead of managing
NATS connections directly.
2026-03-03 12:23:25 -10:00

27 lines
776 B
Go

// Package c4game handles Connect 4 game routes, SSE event streaming, and chat.
package c4game
import (
"github.com/alexedwards/scs/v2"
"github.com/go-chi/chi/v5"
"github.com/ryanhamamura/games/connect4"
"github.com/ryanhamamura/games/features/c4game/services"
)
func SetupRoutes(
router chi.Router,
store *connect4.Store,
svc *services.GameService,
sessions *scs.SessionManager,
) {
router.Route("/games/{id}", func(r chi.Router) {
r.Get("/", HandleGamePage(store, svc, sessions))
r.Get("/events", HandleGameEvents(store, svc, sessions))
r.Post("/drop", HandleDropPiece(store, sessions))
r.Post("/chat", HandleSendChat(store, svc, sessions))
r.Post("/join", HandleSetNickname(store, sessions))
r.Post("/rematch", HandleRematch(store, sessions))
})
}