mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: auth for remote callback / Modify: use map to store hooks in filesystem
This commit is contained in:
17
routers/controllers/callback.go
Normal file
17
routers/controllers/callback.go
Normal 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))
|
||||
}
|
||||
}
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user