feat: Add statusCodeDetails info when returning response in Wasm plugins directly (#1116)

This commit is contained in:
Kent Dong
2024-07-16 09:52:46 +08:00
committed by GitHub
parent 85219b6c53
commit f069ad5b0d
111 changed files with 231 additions and 182 deletions

View File

@@ -44,7 +44,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Lo
res.Code = http.StatusBadRequest
res.Msg = "token or secret 不允许为空"
data, _ := json.Marshal(res)
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, nil, data, -1)
_ = proxywasm.SendHttpResponseWithDetail(http.StatusUnauthorized, "simple-jwt-auth.bad_config", nil, data, -1)
return types.ActionContinue
}
@@ -53,7 +53,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Lo
res.Code = http.StatusUnauthorized
res.Msg = "认证失败"
data, _ := json.Marshal(res)
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, nil, data, -1)
_ = proxywasm.SendHttpResponseWithDetail(http.StatusUnauthorized, "simple-jwt-auth.auth_failed", nil, data, -1)
return types.ActionContinue
}
valid := ParseTokenValid(token, config.TokenSecretKey)
@@ -63,7 +63,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Lo
res.Code = http.StatusUnauthorized
res.Msg = "认证失败"
data, _ := json.Marshal(res)
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, nil, data, -1)
_ = proxywasm.SendHttpResponseWithDetail(http.StatusUnauthorized, "simple-jwt-auth.auth_failed", nil, data, -1)
return types.ActionContinue
}