support redirecting project alternative names
This commit is contained in:
parent
7045794c8e
commit
28e7e769b1
@ -6,6 +6,9 @@ BindTo="0.0.0.0:5656"
|
||||
URL="https://gitea.com/"
|
||||
Org="gitea"
|
||||
|
||||
[Redirect]
|
||||
"old-project-name" = "new-project-name"
|
||||
|
||||
[Template]
|
||||
AppName = "Teafolio"
|
||||
|
||||
|
8
main.go
8
main.go
@ -21,6 +21,7 @@ type Config struct {
|
||||
Gitea struct {
|
||||
URL, Org string
|
||||
}
|
||||
Redirect map[string]string
|
||||
Template struct {
|
||||
AppName string
|
||||
HomepageHeaderHTML string
|
||||
@ -308,6 +309,13 @@ func (this *Application) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Maybe it's a redirected project (alternative name)
|
||||
if rename, ok := this.cfg.Redirect[repoName]; ok {
|
||||
w.Header().Set(`Location`, `/`+url.PathEscape(rename))
|
||||
w.WriteHeader(301)
|
||||
return
|
||||
}
|
||||
|
||||
this.Repopage(w, r, repoName)
|
||||
|
||||
} else if r.URL.Path == `/static/logo.png` {
|
||||
|
Loading…
Reference in New Issue
Block a user