mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 13:05:56 +00:00
Set the default hostname to "0.0.0.0" from "127.0.0.1" - as golang's net.Listener does by default
I changed that because some guys has problems in their hosting machines,
and they should use the "127.0..0.1" instead of "0.0.0.0", if you have
problems just pass `iris.Listen("127.0.0.1:8080") instead of
`iris.Listen(":8080")`
This commit is contained in:
@@ -238,9 +238,14 @@ func (ctx *Context) VirtualHostname() string {
|
||||
}
|
||||
if idxDotAnd := strings.LastIndexByte(hostname, '.'); idxDotAnd > 0 {
|
||||
s := hostname[idxDotAnd:]
|
||||
// means that we have the request's host mymachine.com or 127.0.0.1/0.0.0.0, but for the second option we will need to replace it with the hostname that the dev was registered
|
||||
// this needed to parse correct the {{ url }} iris global template engine's function
|
||||
if s == ".1" {
|
||||
hostname = strings.Replace(hostname, "127.0.0.1", virtualhost, 1)
|
||||
} else if s == ".0" {
|
||||
hostname = strings.Replace(hostname, "0.0.0.0", virtualhost, 1)
|
||||
}
|
||||
//
|
||||
} else {
|
||||
hostname = strings.Replace(hostname, "localhost", virtualhost, 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user