4
This commit is contained in:
parent
650cd1d241
commit
0b1e005c55
1 changed files with 9 additions and 9 deletions
18
router.go
18
router.go
|
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue