feat: add authenticated queue recovery

This commit is contained in:
Josh Creek
2026-08-31 21:29:33 +01:00
parent 236cca30ba
commit 0f1cc17af6
5 changed files with 82 additions and 3 deletions
+14 -1
View File
@@ -98,7 +98,7 @@ func (s *Service) queueCreate(w http.ResponseWriter, r *http.Request) {
}
func (s *Service) queueMutation(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
if r.Method != http.MethodPost && r.Method != http.MethodGet {
writeError(w, http.StatusMethodNotAllowed, "method_not_allowed")
return
}
@@ -111,6 +111,19 @@ func (s *Service) queueMutation(w http.ResponseWriter, r *http.Request) {
return
}
parts := strings.Split(strings.TrimPrefix(r.URL.Path, "/v1/queue/"), "/")
if r.Method == http.MethodGet {
if len(parts) != 1 || parts[0] == "" {
writeError(w, http.StatusNotFound, "not_found")
return
}
ticket, err := s.Queue.Get(playerID, parts[0], s.now())
if err != nil {
writeDomainError(w, err)
return
}
writeJSON(w, http.StatusOK, toQueueResponse(ticket))
return
}
if len(parts) != 2 || parts[0] == "" || (parts[1] != "heartbeat" && parts[1] != "cancel") {
writeError(w, http.StatusNotFound, "not_found")
return