From 60872a1ad76123ecf26ea84afd816fc7fe603dc4 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Mon, 1 Mar 2021 15:13:09 -0800 Subject: [PATCH] Fix list queues handler --- queue_handlers.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/queue_handlers.go b/queue_handlers.go index 45df20a..a856c13 100644 --- a/queue_handlers.go +++ b/queue_handlers.go @@ -20,14 +20,14 @@ func newListQueuesHandlerFunc(inspector *inspeq.Inspector) http.HandlerFunc { http.Error(w, err.Error(), http.StatusInternalServerError) return } - var snapshots []*QueueStateSnapshot - for _, qname := range qnames { + snapshots := make([]*QueueStateSnapshot, len(qnames)) + for i, qname := range qnames { s, err := inspector.CurrentStats(qname) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - snapshots = append(snapshots, toQueueStateSnapshot(s)) + snapshots[i] = toQueueStateSnapshot(s) } payload := map[string]interface{}{"queues": snapshots} json.NewEncoder(w).Encode(payload)