support multi host hopefully
This commit is contained in:
12
main.go
12
main.go
@@ -33,7 +33,8 @@ func main() {
|
||||
}
|
||||
|
||||
func (c Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if c.endpoint(r).To == "" {
|
||||
endpoint := c.endpoint(r)
|
||||
if endpoint.To == "" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
@@ -55,7 +56,6 @@ func (c Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
endpoint := c.endpoint(r)
|
||||
u, err := url.Parse(endpoint.To)
|
||||
if err != nil {
|
||||
log.Printf("[%s] %v", c.key(r), err)
|
||||
@@ -111,7 +111,13 @@ func (c Config) basicAuth(w http.ResponseWriter, r *http.Request) bool {
|
||||
}
|
||||
|
||||
func (c Config) endpoint(r *http.Request) Endpoint {
|
||||
return c.Endpoints[c.key(r)]
|
||||
key := c.key(r)
|
||||
domain := strings.TrimPrefix(r.Host, key)
|
||||
m, ok := c.Domains[domain]
|
||||
if !ok {
|
||||
return Endpoint{}
|
||||
}
|
||||
return m[c.key(r)]
|
||||
}
|
||||
|
||||
type redirPurge struct {
|
||||
|
||||
Reference in New Issue
Block a user