2020-12-24 10:00:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2021-06-06 12:39:42 +00:00
|
|
|
func (a *goBlog) redirectShortDomain(next http.Handler) http.Handler {
|
2020-12-24 10:00:16 +00:00
|
|
|
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
2021-06-06 12:39:42 +00:00
|
|
|
if a.cfg.Server.shortPublicHostname != "" && r.Host == a.cfg.Server.shortPublicHostname {
|
2021-06-10 20:09:50 +00:00
|
|
|
http.Redirect(rw, r, a.getFullAddress(r.RequestURI), http.StatusMovedPermanently)
|
2020-12-24 10:00:16 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
next.ServeHTTP(rw, r)
|
|
|
|
})
|
|
|
|
}
|