MCPcopy Index your code
hub / github.com/coder/coder / wrapTransportWithEntitlementsCheck

Function wrapTransportWithEntitlementsCheck

cli/root.go:1576–1590  ·  view source on GitHub ↗

wrapTransportWithEntitlementsCheck adds a middleware to the HTTP transport that checks for entitlement warnings and prints them to the user.

(rt http.RoundTripper, w io.Writer)

Source from the content-addressed store, hash-verified

1574// wrapTransportWithEntitlementsCheck adds a middleware to the HTTP transport
1575// that checks for entitlement warnings and prints them to the user.
1576func wrapTransportWithEntitlementsCheck(rt http.RoundTripper, w io.Writer) http.RoundTripper {
1577 var once sync.Once
1578 return roundTripper(func(req *http.Request) (*http.Response, error) {
1579 res, err := rt.RoundTrip(req)
1580 if err != nil {
1581 return res, err
1582 }
1583 once.Do(func() {
1584 for _, warning := range res.Header.Values(codersdk.EntitlementsWarningHeader) {
1585 _, _ = fmt.Fprintln(w, pretty.Sprint(cliui.DefaultStyles.Warn, warning))
1586 }
1587 })
1588 return res, err
1589 })
1590}
1591
1592// wrapTransportWithVersionCheck adds a middleware to the HTTP transport
1593// that checks the server version and warns about development builds,

Callers 2

createHTTPClientMethod · 0.85

Calls 3

roundTripperFuncType · 0.70
DoMethod · 0.65
RoundTripMethod · 0.45

Tested by 1