Sort entries in catalog api

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-03-06 17:46:26 +01:00
parent 4b04b7db5a
commit 7838e8e037
Signed by: luzifer
GPG Key ID: D91C3E91E4CAD6F5

3
api.go
View File

@ -6,6 +6,7 @@ import (
"net/http"
"net/url"
"path"
"sort"
"strconv"
"strings"
"time"
@ -157,6 +158,8 @@ func handleCatalogList(w http.ResponseWriter, r *http.Request) {
out[i] = ae
}
sort.Slice(out, func(i, j int) bool { return out[i].Key() < out[j].Key() })
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(out); err != nil {
log.WithError(err).Error("Unable to encode catalog entry list")