- Add brotli compression (level 5) to long-lived SSE event streams (HandleGameEvents, HandleSnakeEvents) to reduce wire payload - Fix all errcheck violations with nolint annotations for best-effort calls - Fix goimports: separate stdlib, third-party, and local import groups - Fix staticcheck: add package comments, use tagged switch - Zero lint issues remaining
31 lines
814 B
Go
31 lines
814 B
Go
// Package lobby handles the game lobby page, game creation, and navigation.
|
|
package lobby
|
|
|
|
import (
|
|
"github.com/ryanhamamura/c4/db/repository"
|
|
"github.com/ryanhamamura/c4/game"
|
|
"github.com/ryanhamamura/c4/snake"
|
|
|
|
"github.com/alexedwards/scs/v2"
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func SetupRoutes(
|
|
router chi.Router,
|
|
queries *repository.Queries,
|
|
sessions *scs.SessionManager,
|
|
store *game.GameStore,
|
|
snakeStore *snake.SnakeStore,
|
|
) error {
|
|
router.Get("/", HandleLobbyPage(queries, sessions, snakeStore))
|
|
|
|
router.Route("/api/lobby", func(r chi.Router) {
|
|
r.Post("/create-game", HandleCreateGame(store, sessions))
|
|
r.Delete("/game/{id}", HandleDeleteGame(store, sessions))
|
|
r.Post("/create-snake", HandleCreateSnakeGame(snakeStore, sessions))
|
|
r.Post("/logout", HandleLogout(sessions))
|
|
})
|
|
|
|
return nil
|
|
}
|