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.
|
||||
type HostRouter struct {
|
||||
Host string
|
||||
type DomainRouter struct {
|
||||
Domain string
|
||||
*mux.Router
|
||||
}
|
||||
|
||||
|
|
@ -24,15 +24,15 @@ func NewRouter() *Router {
|
|||
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)
|
||||
}
|
||||
|
||||
// NewHostRouter creates a new HostRouter for a specific host.
|
||||
func (r *Router) NewHostRouter(host string) *HostRouter {
|
||||
hostRouter := r.NewRoute().Host(host).Subrouter()
|
||||
return &HostRouter{
|
||||
Host: host,
|
||||
Router: hostRouter,
|
||||
// NewDomainRouter creates a new DomainRouter for a specific host.
|
||||
func (r *Router) NewDomainRouter(domain string) *DomainRouter {
|
||||
domainRouter := r.NewRoute().Host(domain).Subrouter()
|
||||
return &DomainRouter{
|
||||
Domain: domain,
|
||||
Router: domainRouter,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue