diff options
author | Martin van Beurden <chadoe@gmail.com> | 2014-09-14 19:35:22 +0200 |
---|---|---|
committer | Martin van Beurden <chadoe@gmail.com> | 2014-09-18 20:50:48 +0200 |
commit | 0055cbd3651ebde0f8b6cc70c9c44de56dc38830 (patch) | |
tree | 64a9ea617ba1f704139881c3960fa2425dad9018 /modules/middleware | |
parent | 4f74b4e6578be4251af65cd08daa37c884e431a0 (diff) | |
download | gitea-0055cbd3651ebde0f8b6cc70c9c44de56dc38830.tar.gz gitea-0055cbd3651ebde0f8b6cc70c9c44de56dc38830.zip |
Allow Gogs to run from a suburl behind a reverse proxy. e.g. http://mydomain.com/gogs/
Conflicts:
modules/setting/setting.go
Conflicts:
templates/repo/release/list.tmpl
templates/user/dashboard/dashboard.tmpl
Conflicts:
routers/repo/setting.go
Diffstat (limited to 'modules/middleware')
-rw-r--r-- | modules/middleware/auth.go | 8 | ||||
-rw-r--r-- | modules/middleware/context.go | 2 | ||||
-rw-r--r-- | modules/middleware/org.go | 7 | ||||
-rw-r--r-- | modules/middleware/repo.go | 12 |
4 files changed, 15 insertions, 14 deletions
diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 51ce48c69b..ccd8d0315d 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -25,13 +25,13 @@ func Toggle(options *ToggleOptions) macaron.Handler { return func(ctx *Context) { // Cannot view any page before installation. if !setting.InstallLock { - ctx.Redirect("/install") + ctx.Redirect(setting.AppRootSubUrl + "/install") return } // Redirect to dashboard if user tries to visit any non-login page. if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" { - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") return } @@ -48,8 +48,8 @@ func Toggle(options *ToggleOptions) macaron.Handler { if strings.HasSuffix(ctx.Req.RequestURI, "watch") { return } - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI)) - ctx.Redirect("/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) + ctx.Redirect(setting.AppRootSubUrl + "/user/login") return } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { ctx.Data["Title"] = ctx.Tr("auth.active_your_account") diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 3ef1b1d620..5c26f91f5e 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -187,7 +187,7 @@ func Contexter() macaron.Handler { Session: sess, } // Compute current URL for real-time change language. - link := ctx.Req.RequestURI + link := setting.AppRootSubUrl + ctx.Req.RequestURI i := strings.Index(link, "?") if i > -1 { link = link[:i] diff --git a/modules/middleware/org.go b/modules/middleware/org.go index 7bb24ab7ee..3a2cf7bc8f 100644 --- a/modules/middleware/org.go +++ b/modules/middleware/org.go @@ -9,6 +9,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/log" + "github.com/gogits/gogs/modules/setting" ) func OrgAssignment(redirect bool, args ...bool) macaron.Handler { @@ -37,7 +38,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetUserByName", err) } else if redirect { log.Error(4, "GetUserByName", err) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } else { ctx.Handle(500, "GetUserByName", err) } @@ -67,7 +68,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { } ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner - ctx.Org.OrgLink = "/org/" + org.Name + ctx.Org.OrgLink = setting.AppRootSubUrl + "/org/" + org.Name ctx.Data["OrgLink"] = ctx.Org.OrgLink // Team. @@ -79,7 +80,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetTeam", err) } else if redirect { log.Error(4, "GetTeam", err) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } else { ctx.Handle(500, "GetTeam", err) } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 82ef3c799e..e7d7fb561d 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -60,7 +60,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetUserByName", err) } else if redirect { log.Error(4, "GetUserByName", err) - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") } else { ctx.Handle(500, "GetUserByName", err) } @@ -72,7 +72,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { if u == nil { if redirect { - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") return } ctx.Handle(404, "RepoAssignment", errors.New("invliad user account for single repository")) @@ -92,7 +92,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetRepositoryByName", err) return } else if redirect { - ctx.Redirect("/") + ctx.Redirect(setting.AppRootSubUrl + "/") return } ctx.Handle(500, "GetRepositoryByName", err) @@ -160,7 +160,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { return } ctx.Repo.GitRepo = gitRepo - ctx.Repo.RepoLink = "/" + u.Name + "/" + repo.Name + ctx.Repo.RepoLink = setting.AppRootSubUrl + "/" + u.Name + "/" + repo.Name ctx.Data["RepoLink"] = ctx.Repo.RepoLink tags, err := ctx.Repo.GitRepo.GetTags() @@ -298,8 +298,8 @@ func RequireTrueOwner() macaron.Handler { return func(ctx *Context) { if !ctx.Repo.IsTrueOwner && !ctx.Repo.IsAdmin { if !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI)) - ctx.Redirect("/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) + ctx.Redirect(setting.AppRootSubUrl + "/user/login") return } ctx.Handle(404, ctx.Req.RequestURI, nil) |