// addRoute adds a route to the index and passes it over to the httprouter
188973
func (r *Router) addRoute(m, p, t string, fn Handle) {

	path := r.subPath(p)

	// Add to index
	if len(t) > 0 && m == "GET" {
		// TODO: Display total path including host
		r.index[t] = path
	}

	// Wrapper function to bypass the parameter problem
	wf := func(w http.ResponseWriter, req *http.Request, p httprouter.Params) {
		fn(w, req, paramsFromHTTPRouter(p))
	}

	r.router.Handle(m, path, wf)
}
1091353
func (n *node) addRoute(path string, handlers HandlersChain) {
	fullPath := path
	n.priority++
	numParams := countParams(path)

	// non-empty tree
	if len(n.path) > 0 || len(n.children) > 0 {
	walk:
		for {
			// Update maxParams of the current node
			if numParams > n.maxParams {
				n.maxParams = numParams
			}

			// Find the longest common prefix.
			// This also implies that the common prefix contains no ':' or '*'
			// since the existing key can't contain those chars.
			i := 0
			max := min(len(path), len(n.path))
			for i < max && path[i] == n.path[i] {
				i++
			}

			// Split edge
			if i < len(n.path) {
				child := node{
					path:      n.path[i:],
					wildChild: n.wildChild,
					indices:   n.indices,
					children:  n.children,
					handlers:  n.handlers,
					priority:  n.priority - 1,
				}

				// Update maxParams (max of all children)
				for i := range child.children {
					if child.children[i].maxParams > child.maxParams {
						child.maxParams = child.children[i].maxParams
					}
				}

				n.children = []*node{&child}
				// []byte for proper unicode char conversion, see #65
				n.indices = string([]byte{n.path[i]})
				n.path = path[:i]
				n.handlers = nil
				n.wildChild = false
			}

			// Make new node a child of this node
			if i < len(path) {
				path = path[i:]

				if n.wildChild {
					n = n.children[0]
					n.priority++

					// Update maxParams of the child node
					if numParams > n.maxParams {
						n.maxParams = numParams
					}
					numParams--

					// Check if the wildcard matches
					if len(path) >= len(n.path) && n.path == path[:len(n.path)] {
						// check for longer wildcard, e.g. :name and :names
						if len(n.path) >= len(path) || path[len(n.path)] == '/' {
							continue walk
						}
					}

					pathSeg := path
					if n.nType != catchAll {
						pathSeg = strings.SplitN(path, "/", 2)[0]
					}
					prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path
					panic("'" + pathSeg +
						"' in new path '" + fullPath +
						"' conflicts with existing wildcard '" + n.path +
						"' in existing prefix '" + prefix +
						"'")
				}

				c := path[0]

				// slash after param
				if n.nType == param && c == '/' && len(n.children) == 1 {
					n = n.children[0]
					n.priority++
					continue walk
				}

				// Check if a child with the next path byte exists
				for i := 0; i < len(n.indices); i++ {
					if c == n.indices[i] {
						i = n.incrementChildPrio(i)
						n = n.children[i]
						continue walk
					}
				}

				// Otherwise insert it
				if c != ':' && c != '*' {
					// []byte for proper unicode char conversion, see #65
					n.indices += string([]byte{c})
					child := &node{
						maxParams: numParams,
					}
					n.children = append(n.children, child)
					n.incrementChildPrio(len(n.indices) - 1)
					n = child
				}
				n.insertChild(numParams, path, fullPath, handlers)
				return

			} else if i == len(path) { // Make node a (in-path) leaf
				if n.handlers != nil {
					panic("handlers are already registered for path '" + fullPath + "'")
				}
				n.handlers = handlers
			}
			return
		}
	} else { // Empty tree
		n.insertChild(numParams, path, fullPath, handlers)
		n.nType = root
	}
}
1011559
func (r *ChannelRouter) AddNode(node *channeldb.LightningNode) error {
	rMsg := &routingMsg{
		msg: node,
		err: make(chan error, 1),
	}

	select {
	case r.networkUpdates <- rMsg:
		select {
		case err := <-rMsg.err:
			return err
		case <-r.quit:
			return ErrRouterShuttingDown
		}
	case <-r.quit:
		return ErrRouterShuttingDown
	}
}
945609
func (this *Router) AddRoute(verb string, path string, funcs ...func(*Request, *Response, func())) {

	route := &Route{
		Method:        strings.ToUpper(verb),
		Path:          path,
		Callbacks:     funcs,
		CaseSensitive: this.CaseSensitive,
		Strict:        this.Strict,
	}

	this.Routes = append(this.Routes, route)
}
699265
func WithRoute(ctx context.Context, r *Route) context.Context {
	return context.WithValue(ctx, routeKey, r)
}
1312679
func (s *VPCRouterSetting) AddStaticRoute(prefix string, nextHop string) (int, *VPCRouterStaticRoutesConfig) {
	if s.StaticRoutes == nil {
		s.StaticRoutes = &VPCRouterStaticRoutes{
			Enabled: "True",
		}
	}
	if s.StaticRoutes.Config == nil {
		s.StaticRoutes.Config = []*VPCRouterStaticRoutesConfig{}
	}

	c := &VPCRouterStaticRoutesConfig{
		Prefix:  prefix,
		NextHop: nextHop,
	}
	s.StaticRoutes.Config = append(s.StaticRoutes.Config, c)
	return len(s.StaticRoutes.Config) - 1, c
}
873133
func (c *client) AddRoute(topic string, callback MessageHandler) {
	if callback != nil {
		c.msgRouter.addRoute(topic, callback)
	}
}
1196449
func (cache *Cache) InstallCronRoute(path string, r *router.Router, base router.MiddlewareChain) {
	m := cache.manager()
	m.installCronRoute(path, r, base)
}
40771
func (s *Server) Get(route string, handler interface{}) {
	s.addRoute(route, "GET", handler)
}
83666
func NewRoute(
	name, method, path string,
	handler types.APIFunc,
	middlewares ...types.Middleware) types.Route {

	return &route{
		name:        name,
		method:      method,
		path:        path,
		handler:     handler,
		middlewares: middlewares,
	}
}
707519
func newRoute() *Route {
	return &Route{
		handlers:   make(map[string]http.Handler),
		middleware: make([]*middlewareForVerb, 0),
		children:   make([]*Route, 0),
	}
}
1004665
func AddRouter(configuration *config.HTTPConfiguration, routerName string, router *config.Router) bool {
	if _, ok := configuration.Routers[routerName]; !ok {
		configuration.Routers[routerName] = router
		return true
	}

	return reflect.DeepEqual(configuration.Routers[routerName], router)
}
896035
func NewRoute(method, path string, handler httputils.APIFunc) dkrouter.Route {
	return localRoute{method, path, handler}
}
103513
func (r *Router) Put(pattern string, handler http.HandlerFunc) {
	r.AddRoute(PUT, pattern, handler)
}
614295
func (r *Router) NewRoute() *Route {
	// initialize a route with a copy of the parent router's configuration
	route := &Route{routeConf: copyRouteConf(r.routeConf), namedRoutes: r.namedRoutes}
	r.routes = append(r.routes, route)
	return route
}
547381
func (m *RouteMux) AddRoute(method string, pattern string, handler http.HandlerFunc) {

	//split the url into sections
	parts := strings.Split(pattern, "/")

	//find params that start with ":"
	//replace with regular expressions
	j := 0
	params := make(map[int]string)
	for i, part := range parts {
		if strings.HasPrefix(part, ":") {
			expr := "([^/]+)"
			//a user may choose to override the defult expression
			// similar to expressjs: ‘/user/:id([0-9]+)’ 
			if index := strings.Index(part, "("); index != -1 {
				expr = part[index:]
				part = part[:index]
			}
			params[j] = part
			parts[i] = expr
			j++
		}
	}

	//recreate the url pattern, with parameters replaced
	//by regular expressions. then compile the regex
	pattern = strings.Join(parts, "/")
	regex, regexErr := regexp.Compile(pattern)
	if regexErr != nil {
		//TODO add error handling here to avoid panic
		panic(regexErr)
		return
	}

	//now create the Route
	route := &route{}
	route.method = method
	route.regex = regex
	route.handler = handler
	route.params = params

	//and finally append to the list of Routes
	m.routes = append(m.routes, route)
}
895134
func AddRoutes(router *mux.Router) {
	var route, listRoute, inspectRoute string

	// Register aciGw
	route = "/api/v1/aciGws/{key}/"
	listRoute = "/api/v1/aciGws/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListAciGws))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetAciGw))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateAciGw))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateAciGw))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteAciGw))

	inspectRoute = "/api/v1/inspect/aciGws/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectAciGw))

	// Register appProfile
	route = "/api/v1/appProfiles/{key}/"
	listRoute = "/api/v1/appProfiles/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListAppProfiles))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetAppProfile))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateAppProfile))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateAppProfile))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteAppProfile))

	inspectRoute = "/api/v1/inspect/appProfiles/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectAppProfile))

	// Register Bgp
	route = "/api/v1/Bgps/{key}/"
	listRoute = "/api/v1/Bgps/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListBgps))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetBgp))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateBgp))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateBgp))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteBgp))

	inspectRoute = "/api/v1/inspect/Bgps/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectBgp))

	inspectRoute = "/api/v1/inspect/endpoints/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectEndpoint))

	// Register endpointGroup
	route = "/api/v1/endpointGroups/{key}/"
	listRoute = "/api/v1/endpointGroups/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListEndpointGroups))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetEndpointGroup))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateEndpointGroup))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateEndpointGroup))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteEndpointGroup))

	inspectRoute = "/api/v1/inspect/endpointGroups/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectEndpointGroup))

	// Register extContractsGroup
	route = "/api/v1/extContractsGroups/{key}/"
	listRoute = "/api/v1/extContractsGroups/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListExtContractsGroups))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetExtContractsGroup))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateExtContractsGroup))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateExtContractsGroup))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteExtContractsGroup))

	inspectRoute = "/api/v1/inspect/extContractsGroups/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectExtContractsGroup))

	// Register global
	route = "/api/v1/globals/{key}/"
	listRoute = "/api/v1/globals/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListGlobals))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetGlobal))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateGlobal))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateGlobal))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteGlobal))

	inspectRoute = "/api/v1/inspect/globals/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectGlobal))

	// Register netprofile
	route = "/api/v1/netprofiles/{key}/"
	listRoute = "/api/v1/netprofiles/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListNetprofiles))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetNetprofile))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateNetprofile))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateNetprofile))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteNetprofile))

	inspectRoute = "/api/v1/inspect/netprofiles/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectNetprofile))

	// Register network
	route = "/api/v1/networks/{key}/"
	listRoute = "/api/v1/networks/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListNetworks))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetNetwork))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateNetwork))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateNetwork))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteNetwork))

	inspectRoute = "/api/v1/inspect/networks/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectNetwork))

	// Register policy
	route = "/api/v1/policys/{key}/"
	listRoute = "/api/v1/policys/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListPolicys))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetPolicy))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreatePolicy))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreatePolicy))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeletePolicy))

	inspectRoute = "/api/v1/inspect/policys/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectPolicy))

	// Register rule
	route = "/api/v1/rules/{key}/"
	listRoute = "/api/v1/rules/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListRules))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetRule))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateRule))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateRule))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteRule))

	inspectRoute = "/api/v1/inspect/rules/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectRule))

	// Register serviceLB
	route = "/api/v1/serviceLBs/{key}/"
	listRoute = "/api/v1/serviceLBs/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListServiceLBs))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetServiceLB))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateServiceLB))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateServiceLB))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteServiceLB))

	inspectRoute = "/api/v1/inspect/serviceLBs/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectServiceLB))

	// Register tenant
	route = "/api/v1/tenants/{key}/"
	listRoute = "/api/v1/tenants/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListTenants))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetTenant))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateTenant))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateTenant))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteTenant))

	inspectRoute = "/api/v1/inspect/tenants/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectTenant))

	// Register volume
	route = "/api/v1/volumes/{key}/"
	listRoute = "/api/v1/volumes/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListVolumes))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetVolume))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateVolume))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateVolume))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteVolume))

	inspectRoute = "/api/v1/inspect/volumes/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectVolume))

	// Register volumeProfile
	route = "/api/v1/volumeProfiles/{key}/"
	listRoute = "/api/v1/volumeProfiles/"
	log.Infof("Registering %s", route)
	router.Path(listRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpListVolumeProfiles))
	router.Path(route).Methods("GET").HandlerFunc(makeHttpHandler(httpGetVolumeProfile))
	router.Path(route).Methods("POST").HandlerFunc(makeHttpHandler(httpCreateVolumeProfile))
	router.Path(route).Methods("PUT").HandlerFunc(makeHttpHandler(httpCreateVolumeProfile))
	router.Path(route).Methods("DELETE").HandlerFunc(makeHttpHandler(httpDeleteVolumeProfile))

	inspectRoute = "/api/v1/inspect/volumeProfiles/{key}/"
	router.Path(inspectRoute).Methods("GET").HandlerFunc(makeHttpHandler(httpInspectVolumeProfile))

}