mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
Nothing special here, just a check on server.Hostname for VListeningAddr
This commit is contained in:
parent
40bc7f5054
commit
c26ce245c7
11
http.go
11
http.go
|
@ -302,7 +302,7 @@ func (s *Server) Listener() net.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Host returns the registered host for the server
|
// Host returns the registered host for the server
|
||||||
func (s *Server) Host() (host string) {
|
func (s *Server) Host() string {
|
||||||
if s.Config.VListeningAddr != "" {
|
if s.Config.VListeningAddr != "" {
|
||||||
return s.Config.VListeningAddr
|
return s.Config.VListeningAddr
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,14 @@ func (s *Server) FullHost() string {
|
||||||
|
|
||||||
// Hostname returns the hostname part of the host (host expect port)
|
// Hostname returns the hostname part of the host (host expect port)
|
||||||
func (s *Server) Hostname() string {
|
func (s *Server) Hostname() string {
|
||||||
return s.Host()[0:strings.IndexByte(s.Host(), ':')] // no the port
|
idxPort := strings.IndexByte(s.Host(), ':')
|
||||||
|
if idxPort > 0 {
|
||||||
|
// port exists, (it always exists for Config.ListeningAddr
|
||||||
|
return s.Host()[0:idxPort] // except the port
|
||||||
|
} // but for Config.VListeningAddr the developer maybe doesn't uses the host:port format
|
||||||
|
|
||||||
|
// so, if no port found, then return the Host as it is, it should be something 'mydomain.com'
|
||||||
|
return s.Host()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) listen() error {
|
func (s *Server) listen() error {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user