package server import ( "net/http/httputil" "net/url" "git.secnex.io/secnex/api-gateway/config" ) type Hosts map[string]*Host type Host struct { ID string Name string Domain string proxy *httputil.ReverseProxy } func NewHosts(cfg *config.Configuration) Hosts { hosts := make(Hosts) for _, host := range cfg.Hosts { hosts[host.ID] = NewHost(&host) } return hosts } func NewHost(host *config.Host) *Host { return &Host{ ID: host.ID, Name: host.Name, Domain: host.Domain, proxy: httputil.NewSingleHostReverseProxy(&url.URL{ Scheme: "https", Host: host.Domain, }), } } func (hs Hosts) GetHost(domain string) *Host { return hs[domain] }