(host string, domain models.DomainFields, path string, port int)
| 86 | } |
| 87 | |
| 88 | func (repo CloudControllerRouteRepository) Find(host string, domain models.DomainFields, path string, port int) (models.Route, error) { |
| 89 | var route models.Route |
| 90 | queryString := queryStringForRouteSearch(host, domain.GUID, path, port) |
| 91 | |
| 92 | q := struct { |
| 93 | Query string `url:"q"` |
| 94 | InlineRelationsDepth int `url:"inline-relations-depth"` |
| 95 | }{queryString, 1} |
| 96 | |
| 97 | opt, _ := query.Values(q) |
| 98 | |
| 99 | found := false |
| 100 | apiErr := repo.gateway.ListPaginatedResources( |
| 101 | repo.config.APIEndpoint(), |
| 102 | fmt.Sprintf("/v2/routes?%s", opt.Encode()), |
| 103 | resources.RouteResource{}, |
| 104 | func(resource interface{}) bool { |
| 105 | keepSearching := true |
| 106 | route = resource.(resources.RouteResource).ToModel() |
| 107 | if doesNotMatchVersionSpecificAttributes(route, path, port) { |
| 108 | return keepSearching |
| 109 | } |
| 110 | |
| 111 | found = true |
| 112 | return !keepSearching |
| 113 | }) |
| 114 | |
| 115 | if apiErr == nil && !found { |
| 116 | apiErr = errors.NewModelNotFoundError("Route", host) |
| 117 | } |
| 118 | |
| 119 | return route, apiErr |
| 120 | } |
| 121 | |
| 122 | func doesNotMatchVersionSpecificAttributes(route models.Route, path string, port int) bool { |
| 123 | return normalizedPath(route.Path) != normalizedPath(path) || route.Port != port |
nothing calls this directly
no test coverage detected