Impl websocket and change all http-get to http-post
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user