mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-24 12:46:38 +00:00
4d16c3adaf
Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.18.0 to 0.19.0. - [Commits](https://github.com/golang/oauth2/compare/v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
29 lines
793 B
Go
29 lines
793 B
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package internal
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
// HTTPClient is the context key to use with golang.org/x/net/context's
|
|
// WithValue function to associate an *http.Client value with a context.
|
|
var HTTPClient ContextKey
|
|
|
|
// ContextKey is just an empty struct. It exists so HTTPClient can be
|
|
// an immutable public variable with a unique type. It's immutable
|
|
// because nobody else can create a ContextKey, being unexported.
|
|
type ContextKey struct{}
|
|
|
|
func ContextClient(ctx context.Context) *http.Client {
|
|
if ctx != nil {
|
|
if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok {
|
|
return hc
|
|
}
|
|
}
|
|
return http.DefaultClient
|
|
}
|