mirror of
https://github.com/kataras/iris.git
synced 2026-01-03 02:07:06 +00:00
Nothing special - Set a server.Config field which can override the ListeningAddr when server.Host()/Port. Mostly used inside glb tmpl funcs
This commit is contained in:
5
http.go
5
http.go
@@ -303,13 +303,16 @@ func (s *Server) Listener() net.Listener {
|
||||
|
||||
// Host returns the registered host for the server
|
||||
func (s *Server) Host() (host string) {
|
||||
if s.Config.VListeningAddr != "" {
|
||||
return s.Config.VListeningAddr
|
||||
}
|
||||
return s.Config.ListeningAddr
|
||||
}
|
||||
|
||||
// Port returns the port which server listening for
|
||||
// if no port given with the ListeningAddr, it returns 80
|
||||
func (s *Server) Port() (port int) {
|
||||
a := s.Config.ListeningAddr
|
||||
a := s.Host()
|
||||
if portIdx := strings.IndexByte(a, ':'); portIdx != -1 {
|
||||
p, err := strconv.Atoi(a[portIdx+1:])
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user