This commit is contained in:
Zeev Diukman 2025-03-06 22:51:45 +00:00
parent 650cd1d241
commit 0b1e005c55

View file

@ -12,8 +12,8 @@ type Router struct {
} }
// HostRouter associates a host with a mux.Router. // HostRouter associates a host with a mux.Router.
type HostRouter struct { type DomainRouter struct {
Host string Domain string
*mux.Router *mux.Router
} }
@ -24,15 +24,15 @@ func NewRouter() *Router {
return r return r
} }
func (r *HostRouter) Handler(handler http.Handler) *mux.Route { func (r *DomainRouter) Handler(handler http.Handler) *mux.Route {
return r.Router.NewRoute().Handler(handler) return r.Router.NewRoute().Handler(handler)
} }
// NewHostRouter creates a new HostRouter for a specific host. // NewDomainRouter creates a new DomainRouter for a specific host.
func (r *Router) NewHostRouter(host string) *HostRouter { func (r *Router) NewDomainRouter(domain string) *DomainRouter {
hostRouter := r.NewRoute().Host(host).Subrouter() domainRouter := r.NewRoute().Host(domain).Subrouter()
return &HostRouter{ return &DomainRouter{
Host: host, Domain: domain,
Router: hostRouter, Router: domainRouter,
} }
} }