summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLinquize <linquize@yahoo.com.hk>2015-03-28 22:30:05 +0800
committerLinquize <linquize@yahoo.com.hk>2015-03-28 22:30:05 +0800
commitf26f8d5afa8d84e4cf3fde6c956dcf907d7883b5 (patch)
treee73ded80d63ff676598505228199a9943bf3d588 /modules
parent9fb2d49b93022d635147c09bcad7134570979909 (diff)
downloadgitea-f26f8d5afa8d84e4cf3fde6c956dcf907d7883b5.tar.gz
gitea-f26f8d5afa8d84e4cf3fde6c956dcf907d7883b5.zip
Set Content-Type to text/plain for http status 401
This is because git command line shows the failure reason only if Content-Type is text/plain.
Diffstat (limited to 'modules')
-rw-r--r--modules/middleware/context.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index b580de5038..200a74cb3a 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -139,6 +139,13 @@ func (ctx *Context) Handle(status int, title string, err error) {
ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status)))
}
+func (ctx *Context) HandleText(status int, title string) {
+ if (status / 100 == 4) || (status / 100 == 5) {
+ log.Error(4, "%s", title)
+ }
+ ctx.RenderData(status, []byte(title))
+}
+
func (ctx *Context) HandleAPI(status int, obj interface{}) {
var message string
if err, ok := obj.(error); ok {