Add ServerBlockIndex and ServerBlockHosts to Controller

This way, Setup functions have access to the list of hosts that share the server block, and also, if needed for some reason, the index of the server block in the input
This commit is contained in:
Matthew Holt
2015-10-15 23:34:54 -06:00
parent 691204ceed
commit 2236780190
3 changed files with 24 additions and 1 deletions
+12
View File
@@ -312,3 +312,15 @@ type (
Host, Port string
}
)
// HostList converts the list of addresses (hosts)
// that are associated with this server block into
// a slice of strings. Each string is a host:port
// combination.
func (sb serverBlock) HostList() []string {
sbHosts := make([]string, len(sb.Addresses))
for j, addr := range sb.Addresses {
sbHosts[j] = net.JoinHostPort(addr.Host, addr.Port)
}
return sbHosts
}