We want to properly handle fallbacks to more general patterns if we
don't find a handler. For instance with this config:
foo.example.org/foo {
file_server /srv/http/foo.example.org
}
*.example.org/bar {
file_server /srv/http/fallback.example.org
}
:80/asdf {
file_server /srv/http/fallback
}
We'll want to route:
* http://foo.example.org/foo to the first handler
* http://foo.example.org/bar to the second one
* http://foo.example.org/asdf to the third one
I think that would be achievable with something like:
type hostServeMux map[string]*http.ServeMux
And in the hostServeMux.ServeHTTP method, first try to find a handler
for the full host:
if pathMux, ok := mux[req.Host]; ok {
if h, pattern := pathMux.Handler(r); pattern != "" {
h.ServeHTTP(w, r)
return
}
}
Then repeat for a potential wildcard name, then repeat with an empty
host.