MCPcopy Create free account
hub / github.com/anchordotdev/cli / get

Method get

api/api.go:348–371  ·  view source on GitHub ↗
(ctx context.Context, uri string, out any)

Source from the content-addressed store, hash-verified

346}
347
348func (s *Session) get(ctx context.Context, uri string, out any) error {
349 req, err := http.NewRequestWithContext(ctx, "GET", uri, nil)
350 if err != nil {
351 return err
352 }
353 if req.URL, err = url.Parse(uri); err != nil {
354 return err
355 }
356 req.Header.Set("Content-Type", "application/json")
357
358 res, err := s.Do(req)
359 if err != nil {
360 return err
361 }
362 if res.StatusCode != http.StatusOK {
363 var errorsRes *Error
364 if err = json.NewDecoder(res.Body).Decode(&errorsRes); err != nil {
365 return err
366 }
367 requestId := res.Header.Get("X-Request-Id")
368 return fmt.Errorf("request [%s]: %w: %s", requestId, StatusCodeError(res.StatusCode), errorsRes.Title)
369 }
370 return json.NewDecoder(res.Body).Decode(out)
371}
372
373func (s *Session) post(ctx context.Context, path string, in, out any) error {
374 var buf bytes.Buffer

Callers 9

GetServiceAttachmentsMethod · 0.95
FetchCredentialsMethod · 0.95
GetCredentialsMethod · 0.95
UserInfoMethod · 0.95
GetOrgsMethod · 0.95
GetOrgRealmsMethod · 0.95
GetOrgServicesMethod · 0.95
GetServiceMethod · 0.95
TestCmdRootFunction · 0.80

Calls 3

StatusCodeErrorTypeAlias · 0.85
SetMethod · 0.80
GetMethod · 0.80

Tested by 1

TestCmdRootFunction · 0.64