当前位置: 首页>>代码示例>>Golang>>正文


Golang Routes.AppRoutes方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.Routes.AppRoutes方法的典型用法代码示例。如果您正苦于以下问题:Golang Routes.AppRoutes方法的具体用法?Golang Routes.AppRoutes怎么用?Golang Routes.AppRoutes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.Routes的用法示例。


在下文中一共展示了Routes.AppRoutes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: buildRoutes

func (appRunner *appRunner) buildRoutes(params CreateAppParams, primaryPort uint16) route_helpers.Routes {
	var routes route_helpers.Routes

	var appRoutes route_helpers.AppRoutes
	if params.NoRoutes {
		appRoutes = route_helpers.AppRoutes{}
	} else if len(params.RouteOverrides) > 0 {
		routeMap := make(map[uint16][]string)
		for _, override := range params.RouteOverrides {
			routeMap[override.Port] = append(routeMap[override.Port], fmt.Sprintf("%s.%s", override.HostnamePrefix, appRunner.systemDomain))
		}
		for port, hostnames := range routeMap {
			appRoutes = append(appRoutes, route_helpers.AppRoute{
				Hostnames: hostnames,
				Port:      port,
			})
		}
	} else {
		appRoutes = appRunner.buildDefaultRoutingInfo(params.Name, params.ExposedPorts, primaryPort)
	}

	var tcpRoutes route_helpers.TcpRoutes
	if !params.NoRoutes && len(params.TcpRoutes) > 0 {
		for _, tcpRoute := range params.TcpRoutes {
			tcpRoutes = append(tcpRoutes, route_helpers.TcpRoute{
				ExternalPort: tcpRoute.ExternalPort,
				Port:         tcpRoute.Port,
			})
		}
		routes.TcpRoutes = tcpRoutes
	}

	routes.AppRoutes = appRoutes
	return routes
}
开发者ID:edwardt,项目名称:lattice,代码行数:35,代码来源:app_runner.go

示例2: buildRoutes

func (appRunner *appRunner) buildRoutes(noRoutes bool, routeOverrides RouteOverrides, tcpRoutes TcpRoutes) route_helpers.Routes {
	var routes route_helpers.Routes

	var appRoutes route_helpers.AppRoutes
	if noRoutes {
		appRoutes = route_helpers.AppRoutes{}
	} else if len(routeOverrides) > 0 {
		routeMap := make(map[uint16][]string)
		for _, override := range routeOverrides {
			routeMap[override.Port] = append(routeMap[override.Port], fmt.Sprintf("%s.%s", override.HostnamePrefix, appRunner.systemDomain))
		}
		for port, hostnames := range routeMap {
			appRoutes = append(appRoutes, route_helpers.AppRoute{
				Hostnames: hostnames,
				Port:      port,
			})
		}
	}

	var appTcpRoutes route_helpers.TcpRoutes
	if !noRoutes && len(tcpRoutes) > 0 {
		for _, tcpRoute := range tcpRoutes {
			appTcpRoutes = append(appTcpRoutes, route_helpers.TcpRoute{
				ExternalPort: tcpRoute.ExternalPort,
				Port:         tcpRoute.Port,
			})
		}
		routes.TcpRoutes = appTcpRoutes
	}

	routes.AppRoutes = appRoutes
	return routes
}
开发者ID:hpcloud,项目名称:lattice,代码行数:33,代码来源:app_runner.go


注:本文中的github.com/cloudfoundry-incubator/lattice/ltc/route_helpers.Routes.AppRoutes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。