//getRoutes returns all registered rest routes
766044
func (sc *ServiceConfig) getRoutes() []rest.Route {

	gz := gzipHandler

	routes := []rest.Route{
		rest.Route{"GET", "/", gz(mainPage)},

		// Backups
		rest.Route{"GET", "/backup/check", gz(sc.authorizedClient(RestBackupCheck))},
		rest.Route{"GET", "/backup/create", gz(sc.authorizedClient(RestBackupCreate))},
		rest.Route{"GET", "/backup/restore", gz(sc.authorizedClient(RestBackupRestore))},
		rest.Route{"GET", "/backup/list", gz(sc.authorizedClient(RestBackupFileList))},
		rest.Route{"GET", "/backup/status", gz(sc.authorizedClient(RestBackupStatus))},
		rest.Route{"GET", "/backup/restore/status", gz(sc.authorizedClient(RestRestoreStatus))},

		// Hosts
		rest.Route{"GET", "/hosts", gz(sc.checkAuth(restGetHosts))},
		rest.Route{"GET", "/hosts/running", gz(sc.checkAuth(restGetActiveHostIDs))},
		rest.Route{"GET", "/hosts/defaultHostAlias", gz(sc.checkAuth(restGetDefaultHostAlias))},
		rest.Route{"GET", "/hosts/:hostId", gz(sc.checkAuth(restGetHost))},
		rest.Route{"POST", "/hosts/add", gz(sc.checkAuth(restAddHost))},
		rest.Route{"DELETE", "/hosts/:hostId", gz(sc.checkAuth(restRemoveHost))},
		rest.Route{"PUT", "/hosts/:hostId", gz(sc.checkAuth(restUpdateHost))},
		rest.Route{"GET", "/hosts/:hostId/running", gz(sc.authorizedClient(restGetRunningForHost))},
		rest.Route{"DELETE", "/hosts/:hostId/:serviceStateId", gz(sc.authorizedClient(restKillRunning))},
		rest.Route{"POST", "/hosts/:hostId/key", gz(sc.checkAuth(restResetHostKey))},

		// Pools
		rest.Route{"GET", "/pools/:poolId", gz(sc.checkAuth(restGetPool))},
		rest.Route{"DELETE", "/pools/:poolId", gz(sc.checkAuth(restRemovePool))},
		rest.Route{"PUT", "/pools/:poolId", gz(sc.checkAuth(restUpdatePool))},
		rest.Route{"POST", "/pools/add", gz(sc.checkAuth(restAddPool))},
		rest.Route{"GET", "/pools", gz(sc.checkAuth(restGetPools))},
		rest.Route{"GET", "/pools/:poolId/hosts", gz(sc.checkAuth(restGetHostsForResourcePool))},

		// Pools (VirtualIP)
		rest.Route{"PUT", "/pools/:poolId/virtualip", gz(sc.checkAuth(restAddPoolVirtualIP))},
		rest.Route{"DELETE", "/pools/:poolId/virtualip/*ip", gz(sc.checkAuth(restRemovePoolVirtualIP))},

		// Pools (IPs)
		rest.Route{"GET", "/pools/:poolId/ips", gz(sc.checkAuth(restGetPoolIps))},

		// Services (Apps)
		rest.Route{"GET", "/services", gz(sc.checkAuth(restGetAllServices))},
		rest.Route{"GET", "/servicehealth", gz(sc.checkAuth(restGetServicesHealth))},
		rest.Route{"GET", "/services/:serviceId", gz(sc.authorizedClient(restGetService))},
		rest.Route{"GET", "/services/:serviceId/running", gz(sc.authorizedClient(restGetRunningForService))},
		rest.Route{"GET", "/services/:serviceId/:serviceStateId/logs", gz(sc.authorizedClient(restGetServiceStateLogs))},
		rest.Route{"GET", "/services/:serviceId/:serviceStateId/logs/download", gz(sc.authorizedClient(downloadServiceStateLogs))},
		rest.Route{"POST", "/services/add", gz(sc.authorizedClient(restAddService))},
		rest.Route{"POST", "/services/deploy", gz(sc.authorizedClient(restDeployService))},
		rest.Route{"PUT", "/services/restartServices", gz(sc.checkAuth(restRestartServices))},
		rest.Route{"PUT", "/services/startServices", gz(sc.checkAuth(restStartServices))},
		rest.Route{"PUT", "/services/stopServices", gz(sc.checkAuth(restStopServices))},
		rest.Route{"DELETE", "/services/:serviceId", gz(sc.checkAuth(restRemoveService))},
		rest.Route{"GET", "/services/:serviceId/logs", gz(sc.authorizedClient(restGetServiceLogs))},
		rest.Route{"PUT", "/services/:serviceId", gz(sc.authorizedClient(restUpdateService))},
		rest.Route{"GET", "/services/:serviceId/snapshot", gz(sc.authorizedClient(restSnapshotService))},
		rest.Route{"PUT", "/services/:serviceId/restartService", gz(sc.checkAuth(restRestartService))},
		rest.Route{"PUT", "/services/:serviceId/startService", gz(sc.checkAuth(restStartService))},
		rest.Route{"PUT", "/services/:serviceId/stopService", gz(sc.checkAuth(restStopService))},
		rest.Route{"POST", "/services/:serviceId/migrate", sc.authorizedClient(restPostServicesForMigration)},

		// Services (Virtual Host)
		rest.Route{"PUT", "/services/:serviceId/endpoint/:application/vhosts/*name", gz(sc.checkAuth(restAddVirtualHost))},
		rest.Route{"DELETE", "/services/:serviceId/endpoint/:application/vhosts/*name", gz(sc.checkAuth(restRemoveVirtualHost))},
		rest.Route{"POST", "/services/:serviceId/endpoint/:application/vhosts/*name", gz(sc.checkAuth(restVirtualHostEnable))},
		// Services (Endpoint Ports)
		rest.Route{"PUT", "/services/:serviceId/endpoint/:application/ports/*portname", gz(sc.checkAuth(restAddPort))},
		rest.Route{"DELETE", "/services/:serviceId/endpoint/:application/ports/*portname", gz(sc.checkAuth(restRemovePort))},
		rest.Route{"POST", "/services/:serviceId/endpoint/:application/ports/*portname", gz(sc.checkAuth(restPortEnable))},

		// Services (IP)
		rest.Route{"PUT", "/services/:serviceId/ip", gz(sc.checkAuth(restServiceAutomaticAssignIP))},
		rest.Route{"PUT", "/services/:serviceId/ip/*ip", gz(sc.checkAuth(restServiceManualAssignIP))},

		// Service templates (App templates)
		rest.Route{"GET", "/templates", gz(sc.checkAuth(restGetAppTemplates))},
		rest.Route{"POST", "/templates/add", gz(sc.checkAuth(restAddAppTemplate))},
		rest.Route{"DELETE", "/templates/:templateId", gz(sc.checkAuth(restRemoveAppTemplate))},
		rest.Route{"POST", "/templates/deploy", gz(sc.checkAuth(restDeployAppTemplate))},
		rest.Route{"POST", "/templates/deploy/status", gz(sc.checkAuth(restDeployAppTemplateStatus))},
		rest.Route{"GET", "/templates/deploy/active", gz(sc.checkAuth(restDeployAppTemplateActive))},

		// Login
		rest.Route{"POST", "/login", gz(sc.noAuth(restLogin))},
		rest.Route{"DELETE", "/login", gz(restLogout)},

		// "Misc" stuff
		rest.Route{"GET", "/top/services", gz(sc.checkAuth(restGetTopServices))},
		rest.Route{"GET", "/config", gz(sc.authorizedClient(restGetUIConfig))},
		rest.Route{"GET", "/servicestatus", gz(sc.checkAuth(restGetConciseServiceStatus))},

		// Generic static data
		rest.Route{"GET", "/favicon.ico", gz(favIcon)},
		rest.Route{"GET", "/static/globals.js", sc.noAuth(restGetAuth0Config)},
		rest.Route{"GET", "/static/*resource", gz(staticData)},
		rest.Route{"GET", "/licenses.html", gz(licenses)},

		// Info about serviced itself
		rest.Route{"GET", "/dockerIsLoggedIn", gz(sc.authorizedClient(restDockerIsLoggedIn))},
		rest.Route{"GET", "/stats", gz(sc.isCollectingStats())},
		rest.Route{"GET", "/version", gz(restGetServicedVersion)},
		rest.Route{"GET", "/storage", gz(sc.authorizedClient(restGetStorage))},

		// V2 API
		rest.Route{"GET", "/api/v2/pools", gz(sc.checkAuth(getPools))},
		rest.Route{"GET", "/api/v2/pools/:poolId/hosts", gz(sc.checkAuth(getHostsForPool))},
		rest.Route{"GET", "/api/v2/hosts", gz(sc.checkAuth(getHosts))},
		rest.Route{"GET", "/api/v2/hosts/:hostId/instances", gz(sc.checkAuth(restGetHostInstances))},
		rest.Route{"GET", "/api/v2/internalservices", gz(sc.checkAuth(getAllInternalServices))},
		rest.Route{"GET", "/api/v2/internalservices/:id", gz(sc.checkAuth(getInternalService))},
		rest.Route{"GET", "/api/v2/internalservices/:id/instances", gz(sc.checkAuth(getInternalServiceInstances))},
		rest.Route{"GET", "/api/v2/internalservicestatuses", gz(sc.checkAuth(getInternalServiceStatuses))},
		rest.Route{"GET", "/api/v2/services", gz(sc.checkAuth(getAllServiceDetails))},
		rest.Route{"GET", "/api/v2/services/:serviceId", gz(sc.checkAuth(getServiceDetails))},
		rest.Route{"PUT", "/api/v2/services/:serviceId", gz(sc.checkAuth(putServiceDetails))},
		rest.Route{"GET", "/api/v2/services/:serviceId/services", gz(sc.checkAuth(getChildServiceDetails))},
		rest.Route{"GET", "/api/v2/services/:serviceId/instances", gz(sc.checkAuth(restGetServiceInstances))},
		rest.Route{"GET", "/api/v2/services/:serviceId/monitoringprofile", gz(sc.checkAuth(restGetServiceMonitoringProfile))},
		rest.Route{"GET", "/api/v2/services/:serviceId/publicendpoints", gz(sc.checkAuth(restGetServicePublicEndpoints))},
		rest.Route{"GET", "/api/v2/services/:serviceId/ipassignments", gz(sc.checkAuth(restGetServiceIPAssignments))},
		rest.Route{"GET", "/api/v2/services/:serviceId/exportendpoints", gz(sc.checkAuth(restGetServiceExportedEndpoints))},
		rest.Route{"GET", "/api/v2/services/:serviceId/descendantstates", gz(sc.checkAuth(restCountDescendantStates))},
		rest.Route{"GET", "/api/v2/services/:serviceId/context", gz(sc.checkAuth(getServiceContext))},
		rest.Route{"PUT", "/api/v2/services/:serviceId/context", gz(sc.checkAuth(putServiceContext))},
		rest.Route{"GET", "/api/v2/statuses", gz(sc.checkAuth(restGetAggregateServices))},
		rest.Route{"GET", "/api/v2/hoststatuses", gz(sc.checkAuth(getHostStatuses))},

		rest.Route{"GET", "/api/v2/services/:serviceId/serviceconfigs", gz(sc.checkAuth(restGetServiceConfigFiles))},
		rest.Route{"POST", "/api/v2/services/:serviceId/serviceconfigs", gz(sc.checkAuth(restAddServiceConfigFile))},
		rest.Route{"GET", "/api/v2/serviceconfigs/:fileId", gz(sc.checkAuth(restGetServiceConfigFile))},
		rest.Route{"PUT", "/api/v2/serviceconfigs/:fileId", gz(sc.checkAuth(restUpdateServiceConfigFile))},
		rest.Route{"DELETE", "/api/v2/serviceconfigs/:fileId", gz(sc.checkAuth(restDeleteServiceConfigFile))},
	}

	// Hardcoding these target URLs for now.
	// TODO: When internal services are allowed to run on other hosts, look that up.
	// All API calls require authentication
	routes = routeToInternalServiceProxy("/api/controlplane/elastic", "http://127.0.0.1:9100/", true, routes)
	routes = routeToInternalServiceProxy("/metrics/api", "http://127.0.0.1:8888/api", true, routes)
	routes = routeToInternalServiceProxy("/api/controlplane/kibana", "http://127.0.0.1:5601", true, routes)

	// Allow static assets for metrics data to be loaded without authentication since they are
	// included in index.html by default.
	routes = routeToInternalServiceProxy("/metrics/static", "http://127.0.0.1:8888/static", false, routes)

	return routes
}
685181
func (client *Client) GetRouteMappings(filters ...Filter) ([]RouteMapping, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.GetRouteMappingsRequest,
		Query:       ConvertFilterParameters(filters),
	})
	if err != nil {
		return nil, nil, err
	}

	var fullRouteMappingsList []RouteMapping
	warnings, err := client.paginate(request, RouteMapping{}, func(item interface{}) error {
		if routeMapping, ok := item.(RouteMapping); ok {
			fullRouteMappingsList = append(fullRouteMappingsList, routeMapping)
		} else {
			return ccerror.UnknownObjectInListError{
				Expected:   RouteMapping{},
				Unexpected: item,
			}
		}
		return nil
	})

	return fullRouteMappingsList, warnings, err
}
338745
func (_m *ClientInterface) GetHosts() ([]host.Host, error) {
	ret := _m.Called()

	var r0 []host.Host
	if rf, ok := ret.Get(0).(func() []host.Host); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]host.Host)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func() error); ok {
		r1 = rf()
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1117988
func (s *RouterService) ListRouters(p *ListRoutersParams) (*ListRoutersResponse, error) {
	resp, err := s.cs.newRequest("listRouters", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListRoutersResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
768937
func (mg *MailgunImpl) GetRoute(ctx context.Context, id string) (Route, error) {
	r := newHTTPRequest(generatePublicApiUrl(mg, routesEndpoint) + "/" + id)
	r.setClient(mg.Client())
	r.setBasicAuth(basicAuthUser, mg.APIKey())
	var envelope struct {
		Message string `json:"message"`
		*Route  `json:"route"`
	}
	err := getResponseFromJSON(ctx, r, &envelope)
	if err != nil {
		return Route{}, err
	}
	return *envelope.Route, err

}
323733
func (c *FakeRoutes) Get(name string, options v1.GetOptions) (result *route.Route, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewGetAction(routesResource, c.ns, name), &route.Route{})

	if obj == nil {
		return nil, err
	}
	return obj.(*route.Route), err
}
739785
func (r *Router) GET(pattern string, handler func(Context)) Route {
	return r.Handle("GET", pattern, wrap(handler))
}
351749
func getRoutes() (routes []RouteEntry, err error) {
	output, err := exec.Command("/sbin/route", "-A", "inet").Output()
	if err != nil {
		return routes, err
	}

	columnMap := make(map[string]int)
	lines := strings.Split(strings.TrimSpace(string(output)), "\n")
	if len(lines) < 2 {
		return routes, fmt.Errorf("no routes found")
	}
	routes = make([]RouteEntry, len(lines)-2)
	for lineNum, line := range lines {
		line = strings.TrimSpace(line)
		switch {
		// skip first line
		case lineNum == 0:
			continue
		case lineNum == 1:
			for number, name := range strings.Fields(line) {
				columnMap[name] = number
			}
			continue
		default:
			fields := strings.Fields(line)
			metric, err := strconv.Atoi(fields[columnMap["Metric"]])
			if err != nil {
				return routes, err
			}
			ref, err := strconv.Atoi(fields[columnMap["Ref"]])
			if err != nil {
				return routes, err
			}
			use, err := strconv.Atoi(fields[columnMap["Use"]])
			if err != nil {
				return routes, err
			}
			routes[lineNum-2] = RouteEntry{
				Destination: fields[columnMap["Destination"]],
				Gateway:     fields[columnMap["Gateway"]],
				Genmask:     fields[columnMap["Genmask"]],
				Flags:       fields[columnMap["Flags"]],
				Metric:      metric,
				Ref:         ref,
				Use:         use,
				Iface:       fields[columnMap["Iface"]],
			}
		}
	}
	return routes, err
}
669433
func (ds *MySQLDatastore) GetRoute(ctx context.Context, appName, routePath string) (*models.Route, error) {
	var route models.Route

	row := ds.db.QueryRow(fmt.Sprintf("%s WHERE app_name=? AND path=?", routeSelector), appName, routePath)
	err := scanRoute(row, &route)

	if err == sql.ErrNoRows {
		return nil, models.ErrRoutesNotFound
	} else if err != nil {
		return nil, err
	}
	return &route, nil
}
1015424
func (c *Cloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error) {
	table, err := c.findRouteTable(clusterName)
	if err != nil {
		return nil, err
	}

	var routes []*cloudprovider.Route
	var instanceIDs []*string

	for _, r := range table.Routes {
		instanceID := orEmpty(r.InstanceId)

		if instanceID == "" {
			continue
		}

		instanceIDs = append(instanceIDs, &instanceID)
	}

	instances, err := c.getInstancesByIDs(instanceIDs)
	if err != nil {
		return nil, err
	}

	for _, r := range table.Routes {
		instanceID := orEmpty(r.InstanceId)
		destinationCIDR := orEmpty(r.DestinationCidrBlock)

		if instanceID == "" || destinationCIDR == "" {
			continue
		}

		instance, found := instances[instanceID]
		if !found {
			glog.Warningf("unable to find instance ID %s in the list of instances being routed to", instanceID)
			continue
		}
		nodeName := mapInstanceToNodeName(instance)
		routeName := clusterName + "-" + destinationCIDR
		routes = append(routes, &cloudprovider.Route{Name: routeName, TargetNode: nodeName, DestinationCIDR: destinationCIDR})
	}

	return routes, nil
}
40771
func (s *Server) Get(route string, handler interface{}) {
	s.addRoute(route, "GET", handler)
}
83262
func (c *Client) GetQueries(ctx context.Context, options *QueryOptions) (*QuerySearch, error) {
	var querySearch QuerySearch

	req, err := c.NewRequest("GET", queryPath, options, nil)
	if err != nil {
		return nil, err
	}

	if err := c.Do(ctx, req, &querySearch); err != nil {
		return nil, err
	}

	return &querySearch, nil
}
825343
func (r *router) GET(path string, handler Route) {
	r.group.GET(path, handler)
}
907682
func (rt *Router) Get(path string, handler http.Handler) {
	rt.Handle(http.MethodGet, path, handler)
}
811588
func (r *router) GET(path string, handle RequestHandler, prefixes []string) {
	r.Handle(GET, path, handle, prefixes)
}
1143021
func (api *MobileGatewayAPI) GetSIMRoutes(id int64) ([]*sacloud.MobileGatewaySIMRoute, error) {
	var (
		method = "GET"
		uri    = fmt.Sprintf("%s/%d/mobilegateway/simroutes", api.getResourceURL(), id)
	)

	data, err := api.client.newRequest(method, uri, nil)
	if err != nil {
		return nil, err
	}
	var res sacloud.MobileGatewaySIMRoutes

	if err := json.Unmarshal(data, &res); err != nil {
		return nil, err
	}
	return res.SIMRoutes, err
}
990669
func (rm *RouteManager) Get(id string) (*Route, error) {
	rm.Lock()
	defer rm.Unlock()
	route, ok := rm.routes[id]
	if !ok {
		return nil, os.ErrNotExist
	}
	return route, nil
}