diff --git a/internal/api/lobby.go b/internal/api/lobby.go
index d10b2c2..f78e4e4 100644
--- a/internal/api/lobby.go
+++ b/internal/api/lobby.go
@@ -1,72 +1,89 @@
package api
import (
- "m1k1o/neko_rooms/internal/utils"
"net/http"
"strings"
"github.com/go-chi/chi"
+
+ "m1k1o/neko_rooms/internal/utils"
)
func (manager *ApiManagerCtx) RoomLobby(w http.ResponseWriter, r *http.Request) {
if !manager.conf.Lobby {
http.NotFound(w, r)
- return
}
roomName := chi.URLParam(r, "roomName")
response, err := manager.rooms.FindByName(roomName)
+
if err != nil || response.Name != roomName {
- utils.Swal2Response(w, `
-
-
-
The room you are trying to join does not exist.
-
- `)
+ manager.roomNotFound(w, r)
return
}
if !response.Running {
- utils.Swal2Response(w, `
-
-
-
The room you are trying to join is not running.
-
- `)
+ manager.roomNotRunning(w, r)
return
}
if strings.Contains(response.Status, "starting") {
- utils.Swal2Response(w, `
-
-
Please wait, until this room is ready so you can join. This should happen any second now.
-
-
+
The room you are trying to join does not exist.
+
+ `)
+}
+
+func (manager *ApiManagerCtx) roomNotRunning(w http.ResponseWriter, r *http.Request) {
+ utils.Swal2Response(w, `
+
+
+
The room you are trying to join is not running.
+
+ `)
+}
+
+func (manager *ApiManagerCtx) roomNotReady(w http.ResponseWriter, r *http.Request) {
+ utils.Swal2Response(w, `
+
+
Please wait, until this room is ready so you can join. This should happen any second now.
+
+