diff options
Diffstat (limited to 'routers/api/v1/misc/markdown.go')
-rw-r--r-- | routers/api/v1/misc/markdown.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/routers/api/v1/misc/markdown.go b/routers/api/v1/misc/markdown.go index 23f0b168d0..5a44db5e8b 100644 --- a/routers/api/v1/misc/markdown.go +++ b/routers/api/v1/misc/markdown.go @@ -36,8 +36,9 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) { // "$ref": "#/responses/MarkdownRender" // "422": // "$ref": "#/responses/validationError" + if ctx.HasAPIError() { - ctx.Error(422, "", ctx.GetErrMsg()) + ctx.Error(http.StatusUnprocessableEntity, "", ctx.GetErrMsg()) return } @@ -65,20 +66,20 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) { if form.Wiki { _, err := ctx.Write([]byte(markdown.RenderWiki(md, urlPrefix, meta))) if err != nil { - ctx.Error(http.StatusInternalServerError, "", err) + ctx.InternalServerError(err) return } } else { _, err := ctx.Write(markdown.Render(md, urlPrefix, meta)) if err != nil { - ctx.Error(http.StatusInternalServerError, "", err) + ctx.InternalServerError(err) return } } default: _, err := ctx.Write(markdown.RenderRaw([]byte(form.Text), "", false)) if err != nil { - ctx.Error(http.StatusInternalServerError, "", err) + ctx.InternalServerError(err) return } } @@ -105,14 +106,15 @@ func MarkdownRaw(ctx *context.APIContext) { // "$ref": "#/responses/MarkdownRender" // "422": // "$ref": "#/responses/validationError" + body, err := ctx.Req.Body().Bytes() if err != nil { - ctx.Error(422, "", err) + ctx.Error(http.StatusUnprocessableEntity, "", err) return } _, err = ctx.Write(markdown.RenderRaw(body, "", false)) if err != nil { - ctx.Error(http.StatusInternalServerError, "", err) + ctx.InternalServerError(err) return } } |