1
0
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:
Gerasimos Maropoulos
2016-07-21 00:03:36 +03:00
parent 352b297977
commit 0dbab32d9d
4 changed files with 11 additions and 6 deletions

View File

@@ -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)
}