mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
{{ url }} prepends with the listening address and not the real host
This commit is contained in:
parent
721e9ef66f
commit
2da67206c8
3
route.go
3
route.go
|
@ -223,8 +223,7 @@ func (r *Route) ParseURI(args ...interface{}) (uri string) {
|
||||||
scheme = "https://"
|
scheme = "https://"
|
||||||
}
|
}
|
||||||
|
|
||||||
host := r.station.server.Host()
|
host := r.station.server.VirtualHost()
|
||||||
|
|
||||||
arguments := args[0:]
|
arguments := args[0:]
|
||||||
|
|
||||||
// join arrays as arguments
|
// join arrays as arguments
|
||||||
|
|
|
@ -67,6 +67,21 @@ func (s *Server) Host() (host string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VirtualHost returns the s.Config.ListeningAddr, if host provided else returns the Listener's (Host())
|
||||||
|
//
|
||||||
|
// Note: currently this is used only on iris/route.ParseURI.
|
||||||
|
//
|
||||||
|
func (s *Server) VirtualHost() (host string) {
|
||||||
|
// we always have at least the :PORT because of parseAddr, so we just
|
||||||
|
// check if we have anything before PORT
|
||||||
|
a := s.Config.ListeningAddr
|
||||||
|
if len(a[0:strings.IndexByte(a, ':')]) > 0 {
|
||||||
|
return a
|
||||||
|
} else {
|
||||||
|
return s.Host()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hostname returns the hostname part only, if host == 0.0.0.0:8080 it will return the 0.0.0.0
|
// Hostname returns the hostname part only, if host == 0.0.0.0:8080 it will return the 0.0.0.0
|
||||||
// if server is not listening it returns the config.ListeningAddr's hostname part
|
// if server is not listening it returns the config.ListeningAddr's hostname part
|
||||||
func (s *Server) Hostname() (hostname string) {
|
func (s *Server) Hostname() (hostname string) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user