コード例 #1
0
ファイル: cloud.go プロジェクト: CowLeo/distribution
// WithContext returns a new context in a similar way NewContext does,
// but initiates the new context with the specified parent.
func WithContext(parent context.Context, projID string, c *http.Client) context.Context {
	// TODO(bradfitz): delete internal.Transport. It's too wrappy for what it does.
	// Do User-Agent some other way.
	if _, ok := c.Transport.(*internal.Transport); !ok {
		c.Transport = &internal.Transport{Base: c.Transport}
	}
	return internal.WithContext(parent, projID, c)
}
コード例 #2
0
ファイル: cloud.go プロジェクト: Celluliodio/flannel
// WithContext returns a new context in a similar way NewContext does,
// but initiates the new context with the specified parent.
func WithContext(parent context.Context, projID string, c *http.Client) context.Context {
	// TODO(bradfitz): delete internal.Transport. It's too wrappy for what it does.
	// Do User-Agent some other way.
	if c == nil {
		panic("invalid nil *http.Client passed to WithContext")
	}
	if _, ok := c.Transport.(*internal.Transport); !ok {
		base := c.Transport
		if base == nil {
			base = http.DefaultTransport
		}
		c.Transport = &internal.Transport{Base: base}
	}
	return internal.WithContext(parent, projID, c)
}