mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-27 18:11:57 +08:00
Feat: remote test ping and ping-back
This commit is contained in:
@@ -151,6 +151,17 @@ func AdminTestPath(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// AdminTestSlave 测试从机可用性
|
||||
func AdminTestSlave(c *gin.Context) {
|
||||
var service admin.SlaveTestService
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.Test()
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// AdminAddPolicy 新建存储策略
|
||||
func AdminAddPolicy(c *gin.Context) {
|
||||
var service admin.AddPolicyService
|
||||
|
||||
@@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
model "github.com/HFO4/cloudreve/models"
|
||||
"github.com/HFO4/cloudreve/pkg/conf"
|
||||
"github.com/HFO4/cloudreve/pkg/serializer"
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -41,7 +42,7 @@ func SiteConfig(c *gin.Context) {
|
||||
func Ping(c *gin.Context) {
|
||||
c.JSON(200, serializer.Response{
|
||||
Code: 0,
|
||||
Msg: "Pong",
|
||||
Data: conf.BackendVersion,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/driver/local"
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/fsctx"
|
||||
"github.com/HFO4/cloudreve/pkg/serializer"
|
||||
"github.com/HFO4/cloudreve/service/admin"
|
||||
"github.com/HFO4/cloudreve/service/explorer"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/url"
|
||||
@@ -146,3 +147,14 @@ func SlaveDelete(c *gin.Context) {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// SlavePing 从机测试
|
||||
func SlavePing(c *gin.Context) {
|
||||
var service admin.SlavePingService
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.Test()
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ func InitSlaveRouter() *gin.Engine {
|
||||
路由
|
||||
*/
|
||||
{
|
||||
// Ping
|
||||
v3.POST("ping", controllers.SlavePing)
|
||||
// 上传
|
||||
v3.POST("upload", controllers.SlaveUpload)
|
||||
// 下载
|
||||
@@ -328,6 +330,8 @@ func InitMasterRouter() *gin.Engine {
|
||||
policy.POST("list", controllers.AdminListPolicy)
|
||||
// 测试本地路径可用性
|
||||
policy.POST("test/path", controllers.AdminTestPath)
|
||||
// 测试从机通信
|
||||
policy.POST("test/slave", controllers.AdminTestSlave)
|
||||
// 创建存储策略
|
||||
policy.POST("", controllers.AdminAddPolicy)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user