Update main.go

This commit is contained in:
澄潭
2024-05-08 10:32:10 +08:00
committed by GitHub
parent a8c74c8302
commit 6577ae8822

View File

@@ -58,15 +58,13 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Lo
}
valid := ParseTokenValid(token, config.TokenSecretKey)
if valid {
_ = proxywasm.ResumeHttpRequest()
return types.ActionPause
} else {
res.Code = http.StatusUnauthorized
res.Msg = "认证失败"
data, _ := json.Marshal(res)
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, nil, data, -1)
return types.ActionContinue
}
res.Code = http.StatusUnauthorized
res.Msg = "认证失败"
data, _ := json.Marshal(res)
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, nil, data, -1)
return types.ActionContinue
}
func ParseTokenValid(tokenString, TokenSecretKey string) bool {