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

Method CreateRequest

api/cloudcontroller/ccv3/internal/routing.go:120–137  ·  view source on GitHub ↗

CreateRequest returns a request key'd off of the name given. The params are merged into the URL and body is set as the request body.

(name string, params Params, body io.Reader)

Source from the content-addressed store, hash-verified

118// CreateRequest returns a request key'd off of the name given. The params are
119// merged into the URL and body is set as the request body.
120func (router Router) CreateRequest(name string, params Params, body io.Reader) (*http.Request, error) {
121 route, ok := router.routes[name]
122 if !ok {
123 return &http.Request{}, fmt.Errorf("no route exists with the name %s", name)
124 }
125
126 uri, err := route.CreatePath(params)
127 if err != nil {
128 return &http.Request{}, err
129 }
130
131 url, err := router.urlFrom(router.baseURL, uri)
132 if err != nil {
133 return &http.Request{}, err
134 }
135
136 return http.NewRequest(route.Method, url, body)
137}
138
139func (Router) urlFrom(resource string, uri string) (string, error) {
140 u, err := url.Parse(resource)

Callers 3

newHTTPRequestMethod · 0.45
routing_test.goFile · 0.45
newHTTPRequestMethod · 0.45

Calls 3

urlFromMethod · 0.95
NewRequestMethod · 0.80
CreatePathMethod · 0.45

Tested by

no test coverage detected