fix list apis (#453)

This commit is contained in:
UUBulb
2024-10-24 10:21:59 +08:00
committed by GitHub
parent 6b650169df
commit 7c784b31b7
6 changed files with 112 additions and 69 deletions

View File

@@ -5,6 +5,7 @@ import (
"strconv"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"github.com/naiba/nezha/model"
"github.com/naiba/nezha/pkg/utils"
@@ -18,12 +19,17 @@ import (
// @Description List server
// @Tags auth required
// @Produce json
// @Success 200 {object} model.CommonResponse[any]
// @Success 200 {object} model.CommonResponse[[]*model.Server]
// @Router /server [get]
func listServer(c *gin.Context) ([]*model.Server, error) {
singleton.SortedServerLock.RLock()
defer singleton.SortedServerLock.RUnlock()
return singleton.SortedServerList, nil
var ssl []*model.Server
if err := copier.Copy(&ssl, &singleton.SortedServerList); err != nil {
return nil, err
}
return ssl, nil
}
// Edit server