Rename module path github.com/ryanhamamura/c4 to github.com/ryanhamamura/games across go.mod, all source files, and golangci config.
29 lines
833 B
Go
29 lines
833 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/nats-io/nats.go"
|
|
|
|
"github.com/ryanhamamura/games/connect4"
|
|
"github.com/ryanhamamura/games/db/repository"
|
|
)
|
|
|
|
func SetupRoutes(
|
|
router chi.Router,
|
|
store *connect4.Store,
|
|
nc *nats.Conn,
|
|
sessions *scs.SessionManager,
|
|
queries *repository.Queries,
|
|
) {
|
|
router.Route("/games/{id}", func(r chi.Router) {
|
|
r.Get("/", HandleGamePage(store, sessions, queries))
|
|
r.Get("/events", HandleGameEvents(store, nc, sessions, queries))
|
|
r.Post("/drop", HandleDropPiece(store, sessions))
|
|
r.Post("/chat", HandleSendChat(store, nc, sessions, queries))
|
|
r.Post("/join", HandleSetNickname(store, sessions))
|
|
r.Post("/rematch", HandleRematch(store, sessions))
|
|
})
|
|
}
|