diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-04-05 06:36:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 06:36:08 +0800 |
commit | 07818d5fa5aef7dd7dca1d556f59c7a146a9b00c (patch) | |
tree | 14c89609a04f269123413f676a8cbe68c197de07 /internal/app/api.go | |
parent | bae1d6ccd81cd427382a2456e7c3646bdac9cf46 (diff) |
route: no session for routes without UI (#6066)
Not all routes need session, register session and CSRF middleware as global is a waste of resource, and creating a lot one-time off yet never used session records.
Diffstat (limited to 'internal/app/api.go')
-rw-r--r-- | internal/app/api.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/internal/app/api.go b/internal/app/api.go index c64e946e..94c2bbc0 100644 --- a/internal/app/api.go +++ b/internal/app/api.go @@ -9,8 +9,6 @@ import ( "github.com/microcosm-cc/bluemonday" "gopkg.in/macaron.v1" - - "gogs.io/gogs/internal/context" ) func ipynbSanitizer() *bluemonday.Policy { @@ -24,13 +22,13 @@ func ipynbSanitizer() *bluemonday.Policy { func SanitizeIpynb() macaron.Handler { p := ipynbSanitizer() - return func(c *context.Context) { + return func(c *macaron.Context) { html, err := c.Req.Body().String() if err != nil { - c.Error(err, "read body") + c.Error(http.StatusInternalServerError, "read body") return } - c.PlainText(http.StatusOK, p.Sanitize(html)) + c.PlainText(http.StatusOK, []byte(p.Sanitize(html))) } } |