本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/api/resources.RouteResource类的典型用法代码示例。如果您正苦于以下问题:Golang RouteResource类的具体用法?Golang RouteResource怎么用?Golang RouteResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RouteResource类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateInSpace
func (repo CloudControllerRouteRepository) CreateInSpace(host, path, domainGuid, spaceGuid string) (createdRoute models.Route, apiErr error) {
data := fmt.Sprintf(`{"host":"%s","path":"%s","domain_guid":"%s","space_guid":"%s"}`, host, path, domainGuid, spaceGuid)
resource := new(resources.RouteResource)
apiErr = repo.gateway.CreateResource(repo.config.ApiEndpoint(), "/v2/routes?inline-relations-depth=1", strings.NewReader(data), resource)
if apiErr != nil {
return
}
createdRoute = resource.ToModel()
return
}
示例2: CreateInSpace
func (repo CloudControllerRouteRepository) CreateInSpace(host, path, domainGUID, spaceGUID string, port int, randomPort bool) (models.Route, error) {
path = normalizedPath(path)
body := struct {
Host string `json:"host,omitempty"`
Path string `json:"path,omitempty"`
Port int `json:"port,omitempty"`
DomainGUID string `json:"domain_guid"`
SpaceGUID string `json:"space_guid"`
}{host, path, port, domainGUID, spaceGUID}
data, err := json.Marshal(body)
if err != nil {
return models.Route{}, err
}
q := struct {
GeneratePort bool `url:"generate_port,omitempty"`
InlineRelationsDepth int `url:"inline-relations-depth"`
}{randomPort, 1}
opt, _ := query.Values(q)
uriFragment := "/v2/routes?" + opt.Encode()
resource := new(resources.RouteResource)
err = repo.gateway.CreateResource(
repo.config.APIEndpoint(),
uriFragment,
bytes.NewReader(data),
resource,
)
if err != nil {
return models.Route{}, err
}
return resource.ToModel(), nil
}