mirror of https://github.com/jlelse/GoBlog
16 lines
403 B
Go
16 lines
403 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
func (a *goBlog) redirectShortDomain(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
|
if a.cfg.Server.shortPublicHostname != "" && r.Host == a.cfg.Server.shortPublicHostname {
|
|
http.Redirect(rw, r, a.getFullAddress(r.RequestURI), http.StatusMovedPermanently)
|
|
return
|
|
}
|
|
next.ServeHTTP(rw, r)
|
|
})
|
|
}
|