summaryrefslogtreecommitdiffstats
path: root/modules/middleware
diff options
context:
space:
mode:
Diffstat (limited to 'modules/middleware')
-rw-r--r--modules/middleware/context.go12
-rw-r--r--modules/middleware/repo.go3
2 files changed, 13 insertions, 2 deletions
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index 28be3a3025..45779d5800 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -130,6 +130,18 @@ func (ctx *Context) Handle(status int, title string, err error) {
ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status)))
}
+func (ctx *Context) HandleAPI(status int, obj interface{}) {
+ var message string
+ if err, ok := obj.(error); ok {
+ message = err.Error()
+ } else {
+ message = obj.(string)
+ }
+ ctx.JSON(status, map[string]string{
+ "message": message,
+ })
+}
+
func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) {
modtime := time.Now()
for _, p := range params {
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index bd298819d7..8188deb534 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -317,8 +317,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
}
ctx.Data["CloneLink"] = ctx.Repo.CloneLink
- if ctx.Repo.Repository.IsGoget {
- ctx.Data["GoGetLink"] = fmt.Sprintf("%s%s/%s", setting.AppUrl, u.LowerName, repo.LowerName)
+ if ctx.Query("go-get") == "1" {
ctx.Data["GoGetImport"] = fmt.Sprintf("%s/%s/%s", setting.Domain, u.LowerName, repo.LowerName)
}