Add num-images and heap-in-use fields to /about
This commit is contained in:
@@ -2,15 +2,23 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
|
||||||
"git.sr.ht/~cwpearson/replicate-jump-server/config"
|
"git.sr.ht/~cwpearson/replicate-jump-server/config"
|
||||||
|
"git.sr.ht/~cwpearson/replicate-jump-server/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AboutGet(c echo.Context) error {
|
func AboutGet(c echo.Context) error {
|
||||||
return c.JSON(http.StatusOK, map[string]string{
|
|
||||||
"version": config.GitSHA(),
|
ms := &runtime.MemStats{}
|
||||||
"build-date": config.BuildDate(),
|
runtime.ReadMemStats(ms)
|
||||||
|
|
||||||
|
return c.JSON(http.StatusOK, map[string]any{
|
||||||
|
"version": config.GitSHA(),
|
||||||
|
"build-date": config.BuildDate(),
|
||||||
|
"num-images": store.NumImages(),
|
||||||
|
"heap-in-use": ms.HeapInuse,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -117,3 +117,10 @@ func Save(data []byte, contentType string) string {
|
|||||||
}
|
}
|
||||||
return store.Save(data, contentType)
|
return store.Save(data, contentType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NumImages() int {
|
||||||
|
if store == nil {
|
||||||
|
store = newStore()
|
||||||
|
}
|
||||||
|
return len(store.images)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user