Impl websocket and change all http-get to http-post

This commit is contained in:
若海
2024-01-19 12:04:34 +08:00
parent c3c22543b9
commit d8e17e0b37
22 changed files with 2449 additions and 1449 deletions
+5 -3
View File
@@ -12,13 +12,15 @@ func ApiGuard(c *gin.Context) {
token := ""
// 取回 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 {
// 校验 Token
if token != args.Web.Token {
c.Set("Error", gin.H{"Code": 401, "Message": "操作未授权"})
c.Set("ExitCode", 401)
c.Abort()
@@ -26,9 +28,9 @@ func ApiGuard(c *gin.Context) {
}
func SwagGuard(c *gin.Context) {
func SwaggerGuard(c *gin.Context) {
if !args.Httpd.Swag && strings.HasPrefix(c.Request.URL.Path, "/swag") {
if !args.Web.Swagger && strings.HasPrefix(c.Request.URL.Path, "/swagger") {
c.Header("Content-Type", "text/html; charset=utf-8")
c.String(200, "功能已禁用")
c.Abort()