1
0
mirror of https://github.com/labstack/echo.git synced 2026-05-16 09:48:24 +02:00
Files
echo/vhost.go
T
toimtoimtoim f071367e3c V5 changes
2026-01-18 18:14:41 +02:00

21 lines
604 B
Go

// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
package echo
import "net/http"
// 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.
func NewVirtualHostHandler(vhosts map[string]*Echo) *Echo {
e := New()
e.serveHTTPFunc = func(w http.ResponseWriter, r *http.Request) {
if vh, ok := vhosts[r.Host]; ok {
vh.ServeHTTP(w, r)
return
}
e.serveHTTP(w, r) // unknown host in request
}
return e
}