NewVirtualHostHandler creates instance of Echo that routes requests to given virtual hosts when hosts in request does not exist in given map the request is served by returned Echo instance.
(vhosts map[string]*Echo)
| 8 | // NewVirtualHostHandler creates instance of Echo that routes requests to given virtual hosts |
| 9 | // when hosts in request does not exist in given map the request is served by returned Echo instance. |
| 10 | func NewVirtualHostHandler(vhosts map[string]*Echo) *Echo { |
| 11 | e := New() |
| 12 | e.serveHTTPFunc = func(w http.ResponseWriter, r *http.Request) { |
| 13 | if vh, ok := vhosts[r.Host]; ok { |
| 14 | vh.ServeHTTP(w, r) |
| 15 | return |
| 16 | } |
| 17 | e.serveHTTP(w, r) // unknown host in request |
| 18 | } |
| 19 | return e |
| 20 | } |
searching dependent graphs…