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

Method ListRoutes

cfapi/ip_route.go:141–158  ·  view source on GitHub ↗

ListRoutes calls the Tunnelstore GET endpoint for all routes under an account. Due to pagination on the server side it will call the endpoint multiple times if needed.

(filter *IpRouteFilter)

Source from the content-addressed store, hash-verified

139// ListRoutes calls the Tunnelstore GET endpoint for all routes under an account.
140// Due to pagination on the server side it will call the endpoint multiple times if needed.
141func (r *RESTClient) ListRoutes(filter *IpRouteFilter) ([]*DetailedRoute, error) {
142 fetchFn := func(page int) (*http.Response, error) {
143 endpoint := r.baseEndpoints.accountRoutes
144 filter.Page(page)
145 endpoint.RawQuery = filter.Encode()
146 rsp, err := r.sendRequest("GET", endpoint, nil)
147
148 if err != nil {
149 return nil, errors.Wrap(err, "REST request failed")
150 }
151 if rsp.StatusCode != http.StatusOK {
152 rsp.Body.Close()
153 return nil, r.statusCodeToError("list routes", rsp)
154 }
155 return rsp, nil
156 }
157 return fetchExhaustively[DetailedRoute](fetchFn)
158}
159
160// AddRoute calls the Tunnelstore POST endpoint for a given route.
161func (r *RESTClient) AddRoute(newRoute NewRoute) (Route, error) {

Callers

nothing calls this directly

Calls 5

sendRequestMethod · 0.95
statusCodeToErrorMethod · 0.95
CloseMethod · 0.65
PageMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected