Documentation ¶
Index ¶
- Variables
- func AuthokClientInfoTransport(base http.RoundTripper, authokClientInfo *AuthokClientInfo) (http.RoundTripper, error)
- func DebugTransport(base http.RoundTripper, debug bool) http.RoundTripper
- func OAuth2ClientCredentials(ctx context.Context, uri, clientID, clientSecret string) oauth2.TokenSource
- func OAuth2ClientCredentialsAndAudience(ctx context.Context, uri, clientID, clientSecret, audience string) oauth2.TokenSource
- func RateLimitTransport(base http.RoundTripper) http.RoundTripper
- func StaticToken(token string) oauth2.TokenSource
- func UserAgentTransport(base http.RoundTripper, userAgent string) http.RoundTripper
- func Wrap(base *http.Client, tokenSource oauth2.TokenSource, options ...Option) *http.Client
- type AuthokClientInfo
- type Option
- type RoundTripFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultAuthokClientInfo = &AuthokClientInfo{ Name: "authok-go", Version: authok.Version, Env: map[string]string{ "go": runtime.Version(), }, }
DefaultAuthokClientInfo is the default client information sent by the authok-go SDK.
var UserAgent = fmt.Sprintf("Authok-Go-SDK/%s", authok.Version)
UserAgent is the default user agent string.
Functions ¶
func AuthokClientInfoTransport ¶
func AuthokClientInfoTransport(base http.RoundTripper, authokClientInfo *AuthokClientInfo) (http.RoundTripper, error)
AuthokClientInfoTransport wraps base transport with a customized "Authok-Client" header.
func DebugTransport ¶
func DebugTransport(base http.RoundTripper, debug bool) http.RoundTripper
DebugTransport wraps base transport with the ability to log the contents of requests and responses.
func OAuth2ClientCredentials ¶
func OAuth2ClientCredentials(ctx context.Context, uri, clientID, clientSecret string) oauth2.TokenSource
OAuth2ClientCredentials sets the oauth2 client credentials.
func OAuth2ClientCredentialsAndAudience ¶
func OAuth2ClientCredentialsAndAudience( ctx context.Context, uri, clientID, clientSecret, audience string, ) oauth2.TokenSource
OAuth2ClientCredentialsAndAudience sets the oauth2 client credentials with a custom audience.
func RateLimitTransport ¶
func RateLimitTransport(base http.RoundTripper) http.RoundTripper
RateLimitTransport wraps base transport with rate limiting functionality.
When a 429 status code is returned by the remote server, the "X-RateLimit-Reset" header is used to determine how long the transport will wait until re-issuing the failed request.
func StaticToken ¶
func StaticToken(token string) oauth2.TokenSource
StaticToken sets a static token to be used for oauth2.
func UserAgentTransport ¶
func UserAgentTransport(base http.RoundTripper, userAgent string) http.RoundTripper
UserAgentTransport wraps base transport with a customized "User-Agent" header.
Types ¶
type AuthokClientInfo ¶
type AuthokClientInfo struct { Name string `json:"name"` Version string `json:"version"` Env map[string]string `json:"env,omitempty"` }
AuthokClientInfo is the structure used to send client information in the "Authok-Client" header.
func (*AuthokClientInfo) IsEmpty ¶
func (td *AuthokClientInfo) IsEmpty() bool
IsEmpty checks whether the provided AuthokClientInfo data is nil or has no data to allow short-circuiting the "Authok-Client" header configuration.
type Option ¶
Option is the type used to configure a client.
func WithAuthokClientInfo ¶
func WithAuthokClientInfo(authokClientInfo *AuthokClientInfo) Option
WithAuthokClientInfo configures the client to overwrite the "Authok-Client" header.
func WithRateLimit ¶
func WithRateLimit() Option
WithRateLimit configures the client to enable rate limiting.
func WithUserAgent ¶
WithUserAgent configures the client to overwrite the user agent header.
type RoundTripFunc ¶
RoundTripFunc is an adapter to allow the use of ordinary functions as HTTP round trips.