1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-16 07:18:37 +00:00

Caller should check the ResponseExtra.HasError() first to see whether the request fails (#28796)

`resp != nil` doesn't mean the request really succeeded. Add a comment
for requestJSONResp to clarify the behavior.
This commit is contained in:
wxiaoguang
2024-01-15 19:15:31 +08:00
committed by GitHub
parent 637451a45e
commit b0e6c25535
4 changed files with 4 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ func AuthorizedPublicKeyByContent(ctx context.Context, content string) (string,
req := newInternalRequest(ctx, reqURL, "POST")
req.Param("content", content)
resp, extra := requestJSONResp(req, &responseText{})
if resp == nil {
if extra.HasError() {
return "", extra
}
return resp.Text, extra