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/"
|
URL="https://gitea.com/"
|
||||||
Org="gitea"
|
Org="gitea"
|
||||||
|
|
||||||
|
[Redirect]
|
||||||
|
"old-project-name" = "new-project-name"
|
||||||
|
|
||||||
[Template]
|
[Template]
|
||||||
AppName = "Teafolio"
|
AppName = "Teafolio"
|
||||||
|
|
||||||
|
8
main.go
8
main.go
@ -21,6 +21,7 @@ type Config struct {
|
|||||||
Gitea struct {
|
Gitea struct {
|
||||||
URL, Org string
|
URL, Org string
|
||||||
}
|
}
|
||||||
|
Redirect map[string]string
|
||||||
Template struct {
|
Template struct {
|
||||||
AppName string
|
AppName string
|
||||||
HomepageHeaderHTML string
|
HomepageHeaderHTML string
|
||||||
@ -308,6 +309,13 @@ func (this *Application) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
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)
|
this.Repopage(w, r, repoName)
|
||||||
|
|
||||||
} else if r.URL.Path == `/static/logo.png` {
|
} else if r.URL.Path == `/static/logo.png` {
|
||||||
|
Loading…
Reference in New Issue
Block a user