Add go http client

This commit is contained in:
若海
2023-12-17 13:16:15 +08:00
parent ccf742aef8
commit 4d9808b584
19 changed files with 2792 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package midware
import (
"strings"
"github.com/gin-gonic/gin"
"github.com/opentdp/wechat-rest/args"
)
func AuthGuard(c *gin.Context) {
token := ""
authcode := c.GetHeader("Authorization")
parts := strings.SplitN(authcode, " ", 2)
if len(parts) == 2 && parts[0] == "Bearer" {
token = parts[1]
}
if token != args.Httpd.Token {
c.Set("Error", gin.H{"Code": 401, "Message": "未授权的操作"})
c.Set("ExitCode", 401)
c.Abort()
}
}