refactor: streamline routes to RESTful naming conventions
All checks were successful
CI / Deploy / test (pull_request) Successful in 13s
CI / Deploy / lint (pull_request) Successful in 23s
CI / Deploy / deploy (pull_request) Has been skipped

Remove /api/ prefix and consolidate route groups:
- /api/lobby/* -> /games, /snake, /logout (top-level)
- /game/{game_id} + /api/game/{game_id}/* -> /games/{id}/*
- /snake/{game_id} + /api/snake/{game_id}/* -> /snake/{id}/*
- /api/auth/* -> /auth/*
- Standardize snake join page to use return_url= (was return=)
This commit is contained in:
Ryan Hamamura
2026-03-02 13:19:03 -10:00
parent fcc6b70e84
commit 5120eef776
18 changed files with 82 additions and 86 deletions

View File

@@ -32,7 +32,7 @@ func getPlayerID(sessions *scs.SessionManager, r *http.Request) snake.PlayerID {
func HandleSnakePage(snakeStore *snake.SnakeStore, sessions *scs.SessionManager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
gameID := chi.URLParam(r, "game_id")
gameID := chi.URLParam(r, "id")
si, ok := snakeStore.Get(gameID)
if !ok {
http.Redirect(w, r, "/", http.StatusSeeOther)
@@ -81,7 +81,7 @@ func HandleSnakePage(snakeStore *snake.SnakeStore, sessions *scs.SessionManager)
func HandleSnakeEvents(snakeStore *snake.SnakeStore, nc *nats.Conn, sessions *scs.SessionManager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
gameID := chi.URLParam(r, "game_id")
gameID := chi.URLParam(r, "id")
si, ok := snakeStore.Get(gameID)
if !ok {
http.Error(w, "game not found", http.StatusNotFound)
@@ -189,7 +189,7 @@ func HandleSnakeEvents(snakeStore *snake.SnakeStore, nc *nats.Conn, sessions *sc
func HandleSetDirection(snakeStore *snake.SnakeStore, sessions *scs.SessionManager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
gameID := chi.URLParam(r, "game_id")
gameID := chi.URLParam(r, "id")
si, ok := snakeStore.Get(gameID)
if !ok {
http.Error(w, "game not found", http.StatusNotFound)
@@ -221,7 +221,7 @@ type chatSignals struct {
func HandleSendChat(snakeStore *snake.SnakeStore, nc *nats.Conn, sessions *scs.SessionManager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
gameID := chi.URLParam(r, "game_id")
gameID := chi.URLParam(r, "id")
si, ok := snakeStore.Get(gameID)
if !ok {
http.Error(w, "game not found", http.StatusNotFound)
@@ -268,7 +268,7 @@ type nicknameSignals struct {
func HandleSetNickname(snakeStore *snake.SnakeStore, sessions *scs.SessionManager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
gameID := chi.URLParam(r, "game_id")
gameID := chi.URLParam(r, "id")
si, ok := snakeStore.Get(gameID)
if !ok {
http.Error(w, "game not found", http.StatusNotFound)
@@ -308,7 +308,7 @@ func HandleSetNickname(snakeStore *snake.SnakeStore, sessions *scs.SessionManage
func HandleRematch(snakeStore *snake.SnakeStore, sessions *scs.SessionManager) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
gameID := chi.URLParam(r, "game_id")
gameID := chi.URLParam(r, "id")
si, ok := snakeStore.Get(gameID)
if !ok {
http.Error(w, "game not found", http.StatusNotFound)