aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/oauth2/internal/transport.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/oauth2/internal/transport.go')
-rw-r--r--vendor/golang.org/x/oauth2/internal/transport.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/golang.org/x/oauth2/internal/transport.go b/vendor/golang.org/x/oauth2/internal/transport.go
new file mode 100644
index 0000000..572074a
--- /dev/null
+++ b/vendor/golang.org/x/oauth2/internal/transport.go
@@ -0,0 +1,33 @@
1// Copyright 2014 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package internal
6
7import (
8 "context"
9 "net/http"
10)
11
12// HTTPClient is the context key to use with golang.org/x/net/context's
13// WithValue function to associate an *http.Client value with a context.
14var HTTPClient ContextKey
15
16// ContextKey is just an empty struct. It exists so HTTPClient can be
17// an immutable public variable with a unique type. It's immutable
18// because nobody else can create a ContextKey, being unexported.
19type ContextKey struct{}
20
21var appengineClientHook func(context.Context) *http.Client
22
23func ContextClient(ctx context.Context) *http.Client {
24 if ctx != nil {
25 if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok {
26 return hc
27 }
28 }
29 if appengineClientHook != nil {
30 return appengineClientHook(ctx)
31 }
32 return http.DefaultClient
33}