mirror of
https://github.com/kataras/iris.git
synced 2025-12-29 15:57:09 +00:00
Nothing special here, just a check on server.Hostname for VListeningAddr
This commit is contained in:
11
http.go
11
http.go
@@ -302,7 +302,7 @@ func (s *Server) Listener() net.Listener {
|
||||
}
|
||||
|
||||
// Host returns the registered host for the server
|
||||
func (s *Server) Host() (host string) {
|
||||
func (s *Server) Host() string {
|
||||
if 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)
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user