(host, path, domainGUID, spaceGUID string, port int, randomPort bool)
| 155 | } |
| 156 | |
| 157 | func (repo CloudControllerRouteRepository) CreateInSpace(host, path, domainGUID, spaceGUID string, port int, randomPort bool) (models.Route, error) { |
| 158 | path = normalizedPath(path) |
| 159 | |
| 160 | body := struct { |
| 161 | Host string `json:"host,omitempty"` |
| 162 | Path string `json:"path,omitempty"` |
| 163 | Port int `json:"port,omitempty"` |
| 164 | DomainGUID string `json:"domain_guid"` |
| 165 | SpaceGUID string `json:"space_guid"` |
| 166 | }{host, path, port, domainGUID, spaceGUID} |
| 167 | |
| 168 | data, err := json.Marshal(body) |
| 169 | if err != nil { |
| 170 | return models.Route{}, err |
| 171 | } |
| 172 | |
| 173 | q := struct { |
| 174 | GeneratePort bool `url:"generate_port,omitempty"` |
| 175 | InlineRelationsDepth int `url:"inline-relations-depth"` |
| 176 | }{randomPort, 1} |
| 177 | |
| 178 | opt, _ := query.Values(q) |
| 179 | uriFragment := "/v2/routes?" + opt.Encode() |
| 180 | |
| 181 | resource := new(resources.RouteResource) |
| 182 | err = repo.gateway.CreateResource( |
| 183 | repo.config.APIEndpoint(), |
| 184 | uriFragment, |
| 185 | bytes.NewReader(data), |
| 186 | resource, |
| 187 | ) |
| 188 | if err != nil { |
| 189 | return models.Route{}, err |
| 190 | } |
| 191 | |
| 192 | return resource.ToModel(), nil |
| 193 | } |
| 194 | |
| 195 | func (repo CloudControllerRouteRepository) Bind(routeGUID, appGUID string) (apiErr error) { |
| 196 | path := fmt.Sprintf("/v2/apps/%s/routes/%s", appGUID, routeGUID) |
no test coverage detected