123456789101112131415161718192021222324252627282930313233 |
- package internal
- import (
- "context"
- "net/http"
- )
- var HTTPClient ContextKey
- type ContextKey struct{}
- var appengineClientHook func(context.Context) *http.Client
- func ContextClient(ctx context.Context) *http.Client {
- if ctx != nil {
- if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok {
- return hc
- }
- }
- if appengineClientHook != nil {
- return appengineClientHook(ctx)
- }
- return http.DefaultClient
- }
|