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 }
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()) } }
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 }
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() {