mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 13:02:33 +02:00
fixed subdomain matching for sub-sub-subdomain and so on, now return 404 when subdomain is missing
This commit is contained in:
parent
f426dbc9cf
commit
99216ffe59
1 changed files with 6 additions and 1 deletions
|
@ -148,7 +148,12 @@ func ProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func findMux(host string) (*http.ServeMux, E.NestedError) {
|
func findMux(host string) (*http.ServeMux, E.NestedError) {
|
||||||
sd := strings.Split(host, ".")[0]
|
hostSplit := strings.Split(host, ".")
|
||||||
|
n := len(hostSplit)
|
||||||
|
if n <= 2 {
|
||||||
|
return nil, E.Missing("subdomain")
|
||||||
|
}
|
||||||
|
sd := strings.Join(hostSplit[:n-2], ".")
|
||||||
if r, ok := httpRoutes.Load(PT.Alias(sd)); ok {
|
if r, ok := httpRoutes.Load(PT.Alias(sd)); ok {
|
||||||
return r.mux, nil
|
return r.mux, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue