// Subrouter ...
773695
func (router *Router) Subrouter(child *Router) *Router {
	router.subrouters = append(router.subrouters, child)
	return router
}
889789
func (addr *Address) Subnet() (*Subnet, error) {
	return addr.st.Subnet(addr.doc.SubnetCIDR)
}
1123386
func (l *Logger) Sub(app byte) *Logger {
	l.mu.RLock()
	defer l.mu.RUnlock()
	return &Logger{
		parent: l,
		app:    app,
	}
}
1093384
func (r *SubRouter) HEAD(route string, handler interface{}) *SubRouter {
	route = r.prefixedRoute(route)
	if r.parent != nil {
		r.parent.handleReg(MethodHEAD, route, handler, r.prefixes)
	}

	return r
}
435629
func NewRouter(b *daemon.Daemon) router.Router {
	r := &buildRouter{
		backend: b,
	}
	r.initRoutes()
	return r
}
247186
func (s *Server) updateRouteSubscriptionMap(acc *Account, sub *subscription, delta int32) {
	if acc == nil || sub == nil {
		return
	}
	acc.mu.RLock()
	rm := acc.rm
	acc.mu.RUnlock()

	// This is non-nil when we know we are in cluster mode.
	if rm == nil {
		return
	}

	// We only store state on local subs for transmission across all other routes.
	if sub.client == nil || (sub.client.kind != CLIENT && sub.client.kind != SYSTEM && sub.client.kind != LEAF) {
		return
	}

	// Create the fast key which will use the subject or 'subject<spc>queue' for queue subscribers.
	var (
		_rkey  [1024]byte
		key    []byte
		update bool
	)
	if sub.queue != nil {
		// Just make the key subject spc group, e.g. 'foo bar'
		key = _rkey[:0]
		key = append(key, sub.subject...)
		key = append(key, byte(' '))
		key = append(key, sub.queue...)
		// We always update for a queue subscriber since we need to send our relative weight.
		update = true
	} else {
		key = sub.subject
	}

	// Copy to hold outside acc lock.
	var n int32
	var ok bool

	acc.mu.Lock()
	if n, ok = rm[string(key)]; ok {
		n += delta
		if n <= 0 {
			delete(rm, string(key))
			update = true // Update for deleting (N->0)
		} else {
			rm[string(key)] = n
		}
	} else if delta > 0 {
		n = delta
		rm[string(key)] = delta
		update = true // Adding a new entry for normal sub means update (0->1)
	}
	acc.mu.Unlock()

	if !update {
		return
	}
	// We need to send out this update.

	// If we are sending a queue sub, copy and place in the queue weight.
	if sub.queue != nil {
		sub.client.mu.Lock()
		nsub := *sub
		sub.client.mu.Unlock()
		nsub.qw = n
		sub = &nsub
	}

	// Note that queue unsubs where entry.n > 0 are still
	// subscribes with a smaller weight.
	if n > 0 {
		s.broadcastSubscribe(sub)
	} else {
		s.broadcastUnSubscribe(sub)
	}
}
1118391
func NewRouter(ctx domain.IContext, ac domain.IAccessController) *Router {
	router := mux.NewRouter().StrictSlash(true)

	return &Router{router, ac, ctx}
}
57957
func (s *Server) InitRouter(routers ...router.Router) {
	s.routers = append(s.routers, routers...)

	m := s.createMux()
	s.routerSwapper = &routerSwapper{
		router: m,
	}
}
262815
func NewRouter() (*Router, error) {
	parser, err := newParser()
	if err != nil {
		return nil, err
	}

	return &Router{
		Router: mux.NewRouter().SkipClean(true),
		parser: parser,
	}, nil
}
463813
func (s *Server) WithRouter(router *mux.Router) *Server {
	s.router = router
	return s
}
924210
func NewRouter(routes Routes) *mux.Router {
	router := mux.NewRouter().StrictSlash(true)
	for _, route := range routes.Routes {
		router.
			Methods(route.Method...).
			Name(route.Name).
			Path(routes.BasePattern + route.Pattern).
			Queries(route.Queries...).
			HandlerFunc(route.HandlerFunc)
	}

	return router
}
1323691
func RegisterRouter(router types.Router) {
	routersRWL.Lock()
	defer routersRWL.Unlock()
	routers = append(routers, router)
}
928695
func (s *Subrouter) Handle(method string, path string, h http.Handler) {
	// calcular path
	fullPath := s.getFullPath(path)
	hrh := func(w http.ResponseWriter, req *http.Request, params map[string]string) {
		httpcontext.Set(req, paramsKey, params)
		s.Stack.Then(h).ServeHTTP(w, req)
	}
	s.router.Handle(method, fullPath, hrh)
}
50759
func BindRouter(router gin.IRouter) {
	for _, apiconf := range registedAPIMethodPathMap {
		method := ParseMethod(apiconf.Method)
		if method == MethodAny {
			router.Any(apiconf.Path, apiconf.Handlers...)
		} else {
			router.Handle(apiconf.Method, apiconf.Path, apiconf.Handlers...)
		}
	}
}
189120
func (s *Subrouter) UseHandler(handler http.Handler) {
	s.Use(func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			handler.ServeHTTP(w, req)
			next.ServeHTTP(w, req)
		})
	})
}
588207
func (r *SubRouter) HTTP() *SubRouter {
	switch parent := r.parent.(type) {
	case *SubRouter:
		return parent.HTTP()
	case *Router:
		return &SubRouter{
			parent: parent,
			prefix: r.prefix,
		}
	default:
		Errorf("[HIGH SEVERITY BUG]: unreachable case found! Expected *SubRouter or *Router, got %T! Returning nil!", parent)
		Errorf("Please report the bug on https://github.com/gramework/gramework ASAP!")
		return nil
	}
}
860149
func (e *environ) Subnets(ctx context.ProviderCallContext, instId instance.Id, subnetIds []network.Id) ([]network.SubnetInfo, error) {
	var results []network.SubnetInfo
	subIdSet := make(map[string]bool)
	for _, subId := range subnetIds {
		subIdSet[string(subId)] = false
	}

	if instId != instance.UnknownId {
		interfaces, err := e.NetworkInterfaces(ctx, instId)
		if err != nil {
			return results, errors.Trace(err)
		}
		if len(subnetIds) == 0 {
			for _, iface := range interfaces {
				subIdSet[string(iface.ProviderSubnetId)] = false
			}
		}
		for _, iface := range interfaces {
			_, ok := subIdSet[string(iface.ProviderSubnetId)]
			if !ok {
				logger.Tracef("subnet %q not in %v, skipping", iface.ProviderSubnetId, subnetIds)
				continue
			}
			subIdSet[string(iface.ProviderSubnetId)] = true
			info, err := makeSubnetInfo(iface.CIDR, iface.ProviderSubnetId, iface.ProviderNetworkId, iface.AvailabilityZones)
			if err != nil {
				// Error will already have been logged.
				continue
			}
			results = append(results, info)
		}
	} else {
		resp, _, err := e.subnetsForVPC(ctx)
		if err != nil {
			return nil, errors.Annotatef(err, "failed to retrieve subnets")
		}
		if len(subnetIds) == 0 {
			for _, subnet := range resp.Subnets {
				subIdSet[subnet.Id] = false
			}
		}

		for _, subnet := range resp.Subnets {
			_, ok := subIdSet[subnet.Id]
			if !ok {
				logger.Tracef("subnet %q not in %v, skipping", subnet.Id, subnetIds)
				continue
			}
			subIdSet[subnet.Id] = true
			cidr := subnet.CIDRBlock
			info, err := makeSubnetInfo(cidr, network.Id(subnet.Id), network.Id(subnet.VPCId), []string{subnet.AvailZone})
			if err != nil {
				// Error will already have been logged.
				continue
			}
			results = append(results, info)

		}
	}

	notFound := []string{}
	for subId, found := range subIdSet {
		if !found {
			notFound = append(notFound, subId)
		}
	}
	if len(notFound) != 0 {
		return nil, errors.Errorf("failed to find the following subnet ids: %v", notFound)
	}

	return results, nil
}