Replace CDN-hosted datastar beta.11 with local v1.0.0-RC.7 to fix client-side expression incompatibilities with the Go SDK. Also fix quoted CSS class keys in data-class expressions, harden session cookie settings (named cookie, Secure flag), simplify SetupRoutes to not return an error, and regenerate templ output.
29 lines
823 B
Go
29 lines
823 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/c4/db/repository"
|
|
"github.com/ryanhamamura/c4/game"
|
|
)
|
|
|
|
func SetupRoutes(
|
|
router chi.Router,
|
|
store *game.GameStore,
|
|
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))
|
|
})
|
|
}
|