MCPcopy
hub / github.com/cloudflare/cloudflared / AddRoute

Method AddRoute

cfapi/ip_route.go:161–175  ·  view source on GitHub ↗

AddRoute calls the Tunnelstore POST endpoint for a given route.

(newRoute NewRoute)

Source from the content-addressed store, hash-verified

159
160// AddRoute calls the Tunnelstore POST endpoint for a given route.
161func (r *RESTClient) AddRoute(newRoute NewRoute) (Route, error) {
162 endpoint := r.baseEndpoints.accountRoutes
163 endpoint.Path = path.Join(endpoint.Path)
164 resp, err := r.sendRequest("POST", endpoint, newRoute)
165 if err != nil {
166 return Route{}, errors.Wrap(err, "REST request failed")
167 }
168 defer resp.Body.Close()
169
170 if resp.StatusCode == http.StatusOK {
171 return parseRoute(resp.Body)
172 }
173
174 return Route{}, r.statusCodeToError("add route", resp)
175}
176
177// DeleteRoute calls the Tunnelstore DELETE endpoint for a given route.
178func (r *RESTClient) DeleteRoute(id uuid.UUID) error {

Callers

nothing calls this directly

Calls 4

sendRequestMethod · 0.95
statusCodeToErrorMethod · 0.95
parseRouteFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected