Feat: auth for remote callback / Modify: use map to store hooks in filesystem

This commit is contained in:
HFO4
2019-12-30 19:08:38 +08:00
parent ca9f44c06c
commit d29b7ef6f8
15 changed files with 158 additions and 59 deletions

View File

@@ -0,0 +1,17 @@
package controllers
import (
"github.com/HFO4/cloudreve/service/callback"
"github.com/gin-gonic/gin"
)
// RemoteCallback 远程上传回调
func RemoteCallback(c *gin.Context) {
var callbackBody callback.RemoteUploadCallbackService
if err := c.ShouldBindJSON(&callbackBody); err == nil {
res := callbackBody.Process(c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}

View File

@@ -114,6 +114,17 @@ func InitMasterRouter() *gin.Engine {
}
}
// 回调接口
callback := v3.Group("callback")
{
// 远程上传回调
callback.POST(
"remote/:key",
middleware.RemoteCallbackAuth(),
controllers.RemoteCallback,
)
}
// 需要登录保护的
auth := v3.Group("")
auth.Use(middleware.AuthRequired())