mirror of
https://github.com/jlelse/GoBlog
synced 2024-06-10 10:47:08 +00:00
16 lines
412 B
Go
16 lines
412 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func redirectShortDomain(next http.Handler) http.Handler {
|
||
|
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||
|
if appConfig.Server.shortPublicHostname != "" && r.Host == appConfig.Server.shortPublicHostname {
|
||
|
http.Redirect(rw, r, appConfig.Server.PublicAddress+r.RequestURI, http.StatusMovedPermanently)
|
||
|
return
|
||
|
}
|
||
|
next.ServeHTTP(rw, r)
|
||
|
})
|
||
|
}
|