// NewRouter initializes returns a new router instance with all the configurations and routes set
13635
func NewRouter(cfg *Config, routes []*Route) *Router {
	handlers := httpHandlers(routes)
	r := &Router{
		optHandlers:    handlers[http.MethodOptions],
		headHandlers:   handlers[http.MethodHead],
		getHandlers:    handlers[http.MethodGet],
		postHandlers:   handlers[http.MethodPost],
		putHandlers:    handlers[http.MethodPut],
		patchHandlers:  handlers[http.MethodPatch],
		deleteHandlers: handlers[http.MethodDelete],

		NotFound:   http.NotFound,
		AppContext: make(map[string]interface{}),
		config:     cfg,
	}

	// setting the default serve handler
	r.serveHandler = r.serve

	return r
}
1190353
func (i *Inbound) SetRouter(router transport.Router) {
	i.transport.router = router
}
438627
func NewRouter(b Backend) router.Router {
	r := &podRouter{
		backend: b,
	}

	r.routes = []router.Route{
		// GET
		local.NewGetRoute("/pod/info", r.getPodInfo),
		local.NewGetRoute("/pod/stats", r.getPodStats),
		local.NewGetRoute("/pod/{id}/portmappings", r.getPortMappings),
		local.NewGetRoute("/list", r.getList),
		// POST
		local.NewPostRoute("/pod/create", r.postPodCreate),
		local.NewPostRoute("/pod/labels", r.postPodLabels),
		local.NewPostRoute("/pod/start", r.postPodStart),
		local.NewPostRoute("/pod/stop", r.postPodStop),
		local.NewPostRoute("/pod/kill", r.postPodKill),
		local.NewPostRoute("/pod/pause", r.postPodPause),
		local.NewPostRoute("/pod/unpause", r.postPodUnpause),
		// PUT
		local.NewPutRoute("/pod/{id}/portmappings/{action}", r.putPortMappings),
		// DELETE
		local.NewDeleteRoute("/pod", r.deletePod),
	}

	return r
}
635511
func NewRouter(logger *log.Logger, localDatacenter string) *Router {
	router := &Router{
		logger:          logger,
		localDatacenter: localDatacenter,
		areas:           make(map[types.AreaID]*areaInfo),
		managers:        make(map[string][]*Manager),
	}

	// Hook the direct route lookup by default.
	router.routeFn = router.findDirectRoute

	return router
}
896035
func NewRoute(method, path string, handler httputils.APIFunc) dkrouter.Route {
	return localRoute{method, path, handler}
}
1179462
func newRouter() *http.ServeMux {
	router := http.NewServeMux()
	router.HandleFunc("/hal/ping", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "PONG")
	})

	router.HandleFunc("/hal/time", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "Server time is: %s\n", time.Now().UTC())
	})

	return router
}
527546
func NewRouter() *Router {
	r := &Router{
		root:               radix.New(),
		storagePrefix:      radix.New(),
		mountUUIDCache:     radix.New(),
		mountAccessorCache: radix.New(),
	}
	return r
}
1288515
func (r *RouteAppenderFactory) NewAppender(ctx context.Context, middlewaresBuilder *middleware.Builder, currentConfiguration *safe.Safe) types.RouteAppender {
	aggregator := NewRouteAppenderAggregator(ctx, middlewaresBuilder, r.staticConfiguration, r.entryPointName, currentConfiguration)

	if r.acmeProvider != nil && r.acmeProvider.HTTPChallenge != nil && r.acmeProvider.HTTPChallenge.EntryPoint == r.entryPointName {
		aggregator.AddAppender(r.acmeProvider)
	}

	return aggregator
}
174713
func New(mws ...Middleware) *Router {
	r := &Router{
		parent:           nil,
		hostrm:           newHostMatcher(),
		middlewares:      Middlewares{},
		namedMiddlewares: make(map[string]Middlewares),
		pool:             newCtxPool(),
	}
	r.Use(mws...)
	r.Configure(
		WithLogger(lionLogger),
		WithServer(&http.Server{
			ReadTimeout:  5 * time.Second,
			WriteTimeout: 10 * time.Second,
		}),
	)
	return r
}
1059625
func NewRouteService(config *routeservice.RouteServiceConfig, routeRegistry registry.Registry, logger logger.Logger) negroni.Handler {
	return &RouteService{
		config:   config,
		registry: routeRegistry,
		logger:   logger,
	}
}
80208
func New(ctx interface{}) *Router {
	validateContext(ctx, nil)

	r := &Router{}
	r.contextType = reflect.TypeOf(ctx)
	r.pathPrefix = "/"
	r.maxChildrenDepth = 1
	r.root = make(map[httpMethod]*pathNode)
	for _, method := range httpMethods {
		r.root[method] = newPathNode()
	}
	return r
}
119437
func New(rp ringpop.Interface, f ClientFactory, ch *tchannel.Channel) Router {
	r := &router{
		ringpop: rp,
		factory: f,
		channel: ch,

		clientCache: make(map[string]cacheEntry),
	}
	rp.AddListener(r)
	return r
}
57957
func (s *Server) InitRouter(routers ...router.Router) {
	s.routers = append(s.routers, routers...)

	m := s.createMux()
	s.routerSwapper = &routerSwapper{
		router: m,
	}
}
1366420
func NewRouter(ctx *Context, next http.Handler) http.Handler {
	if ctx.router == nil {
		ctx.router = DefaultRouter(ctx.spec, ctx.api)
	}

	return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
		if _, rCtx, ok := ctx.RouteInfo(r); ok {
			next.ServeHTTP(rw, rCtx)
			return
		}

		// Not found, check if it exists in the other methods first
		if others := ctx.AllowedMethods(r); len(others) > 0 {
			ctx.Respond(rw, r, ctx.analyzer.RequiredProduces(), nil, errors.MethodNotAllowed(r.Method, others))
			return
		}

		ctx.Respond(rw, r, ctx.analyzer.RequiredProduces(), nil, errors.NotFound("path %s was not found", r.URL.EscapedPath()))
	})
}
819701
func NewDefaultRouter() Router {
	return &defaultRouter{
		realms:                make(map[URI]Realm),
		sessionOpenCallbacks:  []func(uint, string){},
		sessionCloseCallbacks: []func(uint, string){},
	}
}
609677
func newRouter() *router {
	r := &router{
		RedirectTrailingSlash:  true,
		RedirectFixedPath:      true,
		HandleMethodNotAllowed: true,
		HandleOPTIONS:          true,
		cache: &cache{
			v: map[string]*msc{
				// init default methods
				MethodGET: &msc{
					v: make(map[string]*cacheRecord),
				},
				MethodDELETE: &msc{
					v: make(map[string]*cacheRecord),
				},
				MethodHEAD: &msc{
					v: make(map[string]*cacheRecord),
				},
				MethodOPTIONS: &msc{
					v: make(map[string]*cacheRecord),
				},
				MethodPATCH: &msc{
					v: make(map[string]*cacheRecord),
				},
				MethodPOST: &msc{
					v: make(map[string]*cacheRecord),
				},
				MethodPUT: &msc{
					v: make(map[string]*cacheRecord),
				},
			},
		},
	}
	r.StaticHandlers = map[methodIndex]map[string]staticHandler{
		methodToIdx(GET):     make(map[string]staticHandler),
		methodToIdx(DELETE):  make(map[string]staticHandler),
		methodToIdx(HEAD):    make(map[string]staticHandler),
		methodToIdx(OPTIONS): make(map[string]staticHandler),
		methodToIdx(PATCH):   make(map[string]staticHandler),
		methodToIdx(POST):    make(map[string]staticHandler),
		methodToIdx(PUT):     make(map[string]staticHandler),
	}
	go r.cache.maintain()
	return r
}
172752
func NewRouter(nodeKey *btcec.PrivateKey, net *chaincfg.Params, log ReplayLog) *Router {
	var nodeID [AddressSize]byte
	copy(nodeID[:], btcutil.Hash160(nodeKey.PubKey().SerializeCompressed()))

	// Safe to ignore the error here, nodeID is 20 bytes.
	nodeAddr, _ := btcutil.NewAddressPubKeyHash(nodeID[:], net)

	return &Router{
		nodeID:   nodeID,
		nodeAddr: nodeAddr,
		onionKey: &btcec.PrivateKey{
			PublicKey: ecdsa.PublicKey{
				Curve: btcec.S256(),
				X:     nodeKey.X,
				Y:     nodeKey.Y,
			},
			D: nodeKey.D,
		},
		log: log,
	}
}