MCPcopy Index your code
hub / github.com/labstack/echo / NewVirtualHostHandler

Function NewVirtualHostHandler

vhost.go:10–20  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
10func 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}

Callers 1

TestVirtualHostHandlerFunction · 0.85

Calls 3

NewFunction · 0.85
ServeHTTPMethod · 0.80
serveHTTPMethod · 0.80

Tested by 1

TestVirtualHostHandlerFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…