From 21d9946f760a20627009b009503e1bca7d112d61 Mon Sep 17 00:00:00 2001 From: Nikita Zinkevich Date: Fri, 20 Sep 2024 15:20:46 +0300 Subject: [PATCH] [#137] Add index page support Signed-off-by: Nikita Zinkevich --- go.mod | 2 +- internal/handler/browse.go | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index accedfb..7a243db 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20240718141740-ce8270568d36 git.frostfs.info/TrueCloudLab/zapjournald v0.0.0-20240124114243-cb2e66427d02 github.com/bluele/gcache v0.0.2 + github.com/docker/go-units v0.4.0 github.com/fasthttp/router v1.4.1 github.com/nspcc-dev/neo-go v0.106.2 github.com/prometheus/client_golang v1.19.0 @@ -49,7 +50,6 @@ require ( github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/docker v20.10.14+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect - github.com/docker/go-units v0.4.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect diff --git a/internal/handler/browse.go b/internal/handler/browse.go index a8789f2..a010e97 100644 --- a/internal/handler/browse.go +++ b/internal/handler/browse.go @@ -1,6 +1,7 @@ package handler import ( + "cmp" "html/template" "path" "strconv" @@ -91,11 +92,8 @@ func (h *Handler) browseObjects(c *fasthttp.RequestCtx, bucketName, prefix strin } else if !aIsDir && bIsDir { return 1 } - - if a.FileName < b.FileName { - return -1 - } - return 1 + + return cmp.Compare(a.FileName, b.FileName) }) templatePath := h.config.IndexPageTemplatePath()