summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/misc/markdown.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/misc/markdown.go')
-rw-r--r--routers/api/v1/misc/markdown.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/routers/api/v1/misc/markdown.go b/routers/api/v1/misc/markdown.go
index 06e344a15b..b00b00c499 100644
--- a/routers/api/v1/misc/markdown.go
+++ b/routers/api/v1/misc/markdown.go
@@ -5,6 +5,7 @@
package misc
import (
+ "net/http"
"strings"
api "code.gitea.io/gitea/modules/structs"
@@ -42,7 +43,7 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
}
if len(form.Text) == 0 {
- ctx.Write([]byte(""))
+ _, _ = ctx.Write([]byte(""))
return
}
@@ -63,12 +64,24 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
meta = ctx.Repo.Repository.ComposeMetas()
}
if form.Wiki {
- ctx.Write([]byte(markdown.RenderWiki(md, urlPrefix, meta)))
+ _, err := ctx.Write([]byte(markdown.RenderWiki(md, urlPrefix, meta)))
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "", err)
+ return
+ }
} else {
- ctx.Write(markdown.Render(md, urlPrefix, meta))
+ _, err := ctx.Write(markdown.Render(md, urlPrefix, meta))
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "", err)
+ return
+ }
}
default:
- ctx.Write(markdown.RenderRaw([]byte(form.Text), "", false))
+ _, err := ctx.Write(markdown.RenderRaw([]byte(form.Text), "", false))
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "", err)
+ return
+ }
}
}
@@ -98,5 +111,9 @@ func MarkdownRaw(ctx *context.APIContext) {
ctx.Error(422, "", err)
return
}
- ctx.Write(markdown.RenderRaw(body, "", false))
+ _, err = ctx.Write(markdown.RenderRaw(body, "", false))
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "", err)
+ return
+ }
}