httpd: add an API to get data provider status

This commit is contained in:
Nicola Murino
2019-11-14 18:48:01 +01:00
parent f3de83707f
commit 206799ff1c
9 changed files with 111 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package httpd
import (
"net/http"
"github.com/drakkan/sftpgo/dataprovider"
"github.com/drakkan/sftpgo/logger"
"github.com/drakkan/sftpgo/sftpd"
"github.com/drakkan/sftpgo/utils"
@@ -46,6 +47,15 @@ func initializeRouter(staticFilesPath string) {
render.JSON(w, r, utils.GetAppVersion())
})
router.Get(providerStatusPath, func(w http.ResponseWriter, r *http.Request) {
err := dataprovider.GetProviderStatus(dataProvider)
if err != nil {
sendAPIResponse(w, r, err, "", http.StatusInternalServerError)
} else {
sendAPIResponse(w, r, err, "Alive", http.StatusOK)
}
})
router.Get(activeConnectionsPath, func(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, sftpd.GetConnectionsStats())
})