feat: webhook回调支持口令鉴权
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"git.lxtend.com/qqbot/config"
|
||||
"git.lxtend.com/qqbot/constants"
|
||||
"git.lxtend.com/qqbot/handler"
|
||||
"git.lxtend.com/qqbot/model"
|
||||
@@ -186,6 +187,11 @@ func BuildBotHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func RestartBotHandler(c *gin.Context) {
|
||||
token := c.Request.Header.Get("Authorization")
|
||||
if token != config.ConfigManager.GetConfig().WebServer.Token {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
|
||||
return
|
||||
}
|
||||
err := restartProgram()
|
||||
log.Println("重启程序...")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user