未验证 提交 f6c616f1 编写于 作者: R runzexia

parse 401 err, change code to 428

Signed-off-by: Nrunzexia <runzexia@yunify.com>
上级 416719aa
......@@ -172,14 +172,20 @@ func Validate(req *restful.Request, resp *restful.Response) {
res, err := devops.Validate(scmId, req.Request)
if err != nil {
parseErr(err, resp)
log.Error(err)
if jErr, ok := err.(*devops.JkError); ok {
if jErr.Code != http.StatusUnauthorized {
resp.WriteError(jErr.Code, err)
} else {
resp.WriteHeader(http.StatusPreconditionRequired)
}
} else {
resp.WriteError(http.StatusInternalServerError, err)
}
return
}
resp.Header().Set(restful.HEADER_ContentType, restful.MIME_JSON)
if resp.StatusCode() == http.StatusUnauthorized {
resp.WriteHeader(http.StatusPreconditionRequired)
}
resp.Write(res)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册