mirror of
https://github.com/Luzifer/go-latestver.git
synced 2024-11-09 23:50:05 +00:00
Sort entries in catalog api
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
4b04b7db5a
commit
7838e8e037
1 changed files with 3 additions and 0 deletions
3
api.go
3
api.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -157,6 +158,8 @@ func handleCatalogList(w http.ResponseWriter, r *http.Request) {
|
||||||
out[i] = ae
|
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")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
if err := json.NewEncoder(w).Encode(out); err != nil {
|
if err := json.NewEncoder(w).Encode(out); err != nil {
|
||||||
log.WithError(err).Error("Unable to encode catalog entry list")
|
log.WithError(err).Error("Unable to encode catalog entry list")
|
||||||
|
|
Loading…
Reference in a new issue