1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 21:15:56 +00:00
This commit is contained in:
Makis Maropoulos
2016-06-29 18:49:09 +03:00
parent 65184ddaca
commit f57d457d39
3 changed files with 24 additions and 11 deletions

12
http.go
View File

@@ -403,6 +403,18 @@ func (s *Server) Open() error {
s.Config.ListeningAddr = config.DefaultServerHostname + a
}
if s.Config.RedirectTo != "" {
// override the handler and redirect all requests to this addr
s.Handler = func(reqCtx *fasthttp.RequestCtx) {
path := string(reqCtx.Path())
redirectTo := s.Config.RedirectTo
if path != "/" {
redirectTo += "/" + path
}
reqCtx.Redirect(redirectTo, StatusMovedPermanently)
}
}
if s.Config.Mode > 0 {
return s.listenUNIX()
}