MCPcopy Index your code
hub / github.com/cloudfoundry/cli / CreateInSpace

Method CreateInSpace

cf/api/routes.go:157–193  ·  view source on GitHub ↗
(host, path, domainGUID, spaceGUID string, port int, randomPort bool)

Source from the content-addressed store, hash-verified

155}
156
157func (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
195func (repo CloudControllerRouteRepository) Bind(routeGUID, appGUID string) (apiErr error) {
196 path := fmt.Sprintf("/v2/apps/%s/routes/%s", appGUID, routeGUID)

Callers 1

CreateMethod · 0.95

Calls 4

normalizedPathFunction · 0.85
CreateResourceMethod · 0.80
APIEndpointMethod · 0.65
ToModelMethod · 0.45

Tested by

no test coverage detected