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.
22 lines
759 B
Go
22 lines
759 B
Go
// Package snakegame handles snake game routes, SSE event streaming, and chat.
|
|
package snakegame
|
|
|
|
import (
|
|
"github.com/alexedwards/scs/v2"
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/nats-io/nats.go"
|
|
|
|
"github.com/ryanhamamura/c4/snake"
|
|
)
|
|
|
|
func SetupRoutes(router chi.Router, snakeStore *snake.SnakeStore, nc *nats.Conn, sessions *scs.SessionManager) {
|
|
router.Route("/snake/{id}", func(r chi.Router) {
|
|
r.Get("/", HandleSnakePage(snakeStore, sessions))
|
|
r.Get("/events", HandleSnakeEvents(snakeStore, nc, sessions))
|
|
r.Post("/dir", HandleSetDirection(snakeStore, sessions))
|
|
r.Post("/chat", HandleSendChat(snakeStore, nc, sessions))
|
|
r.Post("/join", HandleSetNickname(snakeStore, sessions))
|
|
r.Post("/rematch", HandleRematch(snakeStore, sessions))
|
|
})
|
|
}
|