summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/misc/signing.go
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-09-21 04:20:14 +0800
committerGitHub <noreply@github.com>2020-09-20 21:20:14 +0100
commitfec152155543e72f2e03885d431642887ce09d69 (patch)
tree6ba0d440eec9df315c8acf487918036717cf98f0 /routers/api/v1/misc/signing.go
parente7ffc67ad5add193e90219a856935bf643b33fe1 (diff)
downloadgitea-fec152155543e72f2e03885d431642887ce09d69.tar.gz
gitea-fec152155543e72f2e03885d431642887ce09d69.zip
Not using "ctx.ServerError" in api (#12907)
This function will render a whole html page which is not useful for API. Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'routers/api/v1/misc/signing.go')
-rw-r--r--routers/api/v1/misc/signing.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/routers/api/v1/misc/signing.go b/routers/api/v1/misc/signing.go
index 0b295f3898..3c3391bfe7 100644
--- a/routers/api/v1/misc/signing.go
+++ b/routers/api/v1/misc/signing.go
@@ -10,11 +10,10 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/log"
)
// SigningKey returns the public key of the default signing key if it exists
-func SigningKey(ctx *context.Context) {
+func SigningKey(ctx *context.APIContext) {
// swagger:operation GET /signing-key.gpg miscellaneous getSigningKey
// ---
// summary: Get default signing-key.gpg
@@ -55,12 +54,11 @@ func SigningKey(ctx *context.Context) {
content, err := models.PublicSigningKey(path)
if err != nil {
- ctx.ServerError("gpg export", err)
+ ctx.Error(http.StatusInternalServerError, "gpg export", err)
return
}
_, err = ctx.Write([]byte(content))
if err != nil {
- log.Error("Error writing key content %v", err)
- ctx.Error(http.StatusInternalServerError, fmt.Sprintf("%v", err))
+ ctx.Error(http.StatusInternalServerError, "gpg export", fmt.Errorf("Error writing key content %v", err))
}
}