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

Method RoundTripper

api/api.go:495–519  ·  view source on GitHub ↗
(next http.RoundTripper)

Source from the content-addressed store, hash-verified

493}
494
495func (s preferSetter) RoundTripper(next http.RoundTripper) http.RoundTripper {
496 return RoundTripFunc(func(req *http.Request) (*http.Response, error) {
497 path := req.URL.Path
498
499 var value []string
500
501 if s.cfg.Test.Prefer[path].Code != 0 {
502 value = append(value, fmt.Sprintf("code=%d", s.cfg.Test.Prefer[path].Code))
503 }
504
505 if s.cfg.Test.Prefer[path].Dynamic {
506 value = append(value, fmt.Sprintf("dynamic=%t", s.cfg.Test.Prefer[path].Dynamic))
507 }
508
509 if s.cfg.Test.Prefer[path].Example != "" {
510 value = append(value, fmt.Sprintf("example=%s", s.cfg.Test.Prefer[path].Example))
511 }
512
513 if len(value) > 0 {
514 req.Header.Set("Prefer", strings.Join(value, " "))
515 }
516
517 return next.RoundTrip(req)
518 })
519}
520
521var userAgentSetter = MiddlewareFunc(func(next http.RoundTripper) http.RoundTripper {
522 return RoundTripFunc(func(req *http.Request) (*http.Response, error) {

Callers

nothing calls this directly

Calls 3

RoundTripFuncFuncType · 0.85
SetMethod · 0.80
RoundTripMethod · 0.45

Tested by

no test coverage detected