(next http.RoundTripper)
| 493 | } |
| 494 | |
| 495 | func (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 | |
| 521 | var userAgentSetter = MiddlewareFunc(func(next http.RoundTripper) http.RoundTripper { |
| 522 | return RoundTripFunc(func(req *http.Request) (*http.Response, error) { |
nothing calls this directly
no test coverage detected