MCPcopy Create free account
hub / github.com/cloudfoundry/cli / CreatePath

Method CreatePath

api/uaa/internal/routing.go:87–107  ·  view source on GitHub ↗

CreatePath combines the route's path pattern with a Params map to produce a valid path.

(params Params)

Source from the content-addressed store, hash-verified

85// CreatePath combines the route's path pattern with a Params map
86// to produce a valid path.
87func (r Route) CreatePath(params Params) (string, error) {
88 components := strings.Split(r.Path, "/")
89 for i, c := range components {
90 if len(c) == 0 {
91 continue
92 }
93 if c[0] == ':' {
94 val, ok := params[c[1:]]
95 if !ok {
96 return "", fmt.Errorf("missing param %s", c)
97 }
98 components[i] = val
99 }
100 }
101
102 u, err := url.Parse(strings.Join(components, "/"))
103 if err != nil {
104 return "", err
105 }
106 return u.String(), nil
107}
108
109// Router combines route and resource information in order to generate HTTP
110// requests.

Callers 2

routing_test.goFile · 0.45
CreateRequestMethod · 0.45

Calls 2

ParseMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected