當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Route.URL方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/models.Route.URL方法的典型用法代碼示例。如果您正苦於以下問題:Golang Route.URL方法的具體用法?Golang Route.URL怎麽用?Golang Route.URL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry/cli/cf/models.Route的用法示例。


在下文中一共展示了Route.URL方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: BindRoute

func (routeActor routeActor) BindRoute(app models.Application, route models.Route) error {
	if !app.HasRoute(route) {
		routeActor.ui.Say(T(
			"Binding {{.URL}} to {{.AppName}}...",
			map[string]interface{}{
				"URL":     terminal.EntityNameColor(route.URL()),
				"AppName": terminal.EntityNameColor(app.Name),
			}),
		)

		err := routeActor.routeRepo.Bind(route.GUID, app.GUID)
		switch err := err.(type) {
		case nil:
			routeActor.ui.Ok()
			routeActor.ui.Say("")
			return nil
		case errors.HTTPError:
			if err.ErrorCode() == errors.InvalidRelation {
				return errors.New(T(
					"The route {{.URL}} is already in use.\nTIP: Change the hostname with -n HOSTNAME or use --random-route to generate a new route and then push again.",
					map[string]interface{}{
						"URL": route.URL(),
					}),
				)
			}
		}
		return err
	}
	return nil
}
開發者ID:jasonkeene,項目名稱:cli,代碼行數:30,代碼來源:routes.go

示例2: BindRoute

func (routeActor RouteActor) BindRoute(app models.Application, route models.Route) {
	if !app.HasRoute(route) {
		routeActor.ui.Say("Binding %s to %s...", terminal.EntityNameColor(route.URL()), terminal.EntityNameColor(app.Name))

		apiErr := routeActor.routeRepo.Bind(route.Guid, app.Guid)
		switch apiErr := apiErr.(type) {
		case nil:
			routeActor.ui.Ok()
			routeActor.ui.Say("")
			return
		case errors.HttpError:
			if apiErr.ErrorCode() == errors.INVALID_RELATION {
				routeActor.ui.Failed("The route %s is already in use.\nTIP: Change the hostname with -n HOSTNAME or use --random-route to generate a new route and then push again.", route.URL())
			}
		}
		routeActor.ui.Failed(apiErr.Error())
	}
}
開發者ID:palakmathur,項目名稱:cli,代碼行數:18,代碼來源:routes.go

示例3: FindOrCreateRoute

func (routeActor routeActor) FindOrCreateRoute(hostname string, domain models.DomainFields, path string, port int, useRandomPort bool) (models.Route, error) {
	var route models.Route
	var err error
	//if tcp route use random port should skip route lookup
	if useRandomPort && domain.RouterGroupType == tcp {
		err = new(errors.ModelNotFoundError)
	} else {
		route, err = routeActor.routeRepo.Find(hostname, domain, path, port)
	}

	switch err.(type) {
	case nil:
		routeActor.ui.Say(
			T("Using route {{.RouteURL}}",
				map[string]interface{}{
					"RouteURL": terminal.EntityNameColor(route.URL()),
				}),
		)
	case *errors.ModelNotFoundError:
		if useRandomPort && domain.RouterGroupType == tcp {
			route, err = routeActor.CreateRandomTCPRoute(domain)
		} else {
			routeActor.ui.Say(
				T("Creating route {{.Hostname}}...",
					map[string]interface{}{
						"Hostname": terminal.EntityNameColor(domain.URLForHostAndPath(hostname, path, port)),
					}),
			)

			route, err = routeActor.routeRepo.Create(hostname, domain, path, port, false)
		}

		routeActor.ui.Ok()
		routeActor.ui.Say("")
	}

	return route, err
}
開發者ID:jasonkeene,項目名稱:cli,代碼行數:38,代碼來源:routes.go

示例4:

			r = models.Route{
				Host: host,
				Domain: models.DomainFields{
					Name: "the-domain",
				},
				Path: path,
			}
		})

		Context("when the host is blank", func() {
			BeforeEach(func() {
				host = ""
			})

			It("returns the domain", func() {
				Expect(r.URL()).To(Equal("the-domain"))
			})

			Context("when the path is present", func() {
				BeforeEach(func() {
					path = "the-path"
				})

				It("returns the domain and path", func() {
					Expect(r.URL()).To(Equal("the-domain/the-path"))
				})
			})
		})

		Context("when the host is not blank", func() {
			BeforeEach(func() {
開發者ID:Reejoshi,項目名稱:cli,代碼行數:31,代碼來源:route_test.go


注:本文中的github.com/cloudfoundry/cli/cf/models.Route.URL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。