Documentation ¶
Index ¶
- Constants
- func IsResponseRedirect(statusCode int) bool
- func IsStatusIn(statusCode int, statuses ...int) bool
- func IsStatusSuccess(statusCode int) bool
- type ClientProvider
- type Executor
- type OAuthSessionManager
- type Request
- func (r *Request) WithBody(body io.Reader) *Request
- func (r *Request) WithContentLength(len int64) *Request
- func (r *Request) WithContentType(contentType string) *Request
- func (r *Request) WithFollowRedirects(follow bool) *Request
- func (r *Request) WithHeader(name, value string) *Request
- func (r *Request) WithObject(obj any) *Request
- type UnauthenticatedClientProvider
Constants ¶
const DefaultContentType = "application/json"
Variables ¶
This section is empty.
Functions ¶
func IsResponseRedirect ¶
func IsStatusIn ¶
func IsStatusSuccess ¶
Types ¶
type ClientProvider ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor handles executing HTTP requests
func NewExecutor ¶
func NewExecutor(clientProvider ClientProvider, apiAddress, userAgent string) *Executor
NewExecutor creates a new HTTP Executor instance
type OAuthSessionManager ¶
type OAuthSessionManager struct {
// contains filtered or unexported fields
}
OAuthSessionManager creates and manages OAuth http client instances
func NewOAuthSessionManager ¶
func NewOAuthSessionManager(config *config.Config) *OAuthSessionManager
NewOAuthSessionManager creates a new OAuth session manager
func (*OAuthSessionManager) AccessToken ¶
func (m *OAuthSessionManager) AccessToken(ctx context.Context) (string, error)
AccessToken returns the raw OAuth access token
func (*OAuthSessionManager) Client ¶
func (m *OAuthSessionManager) Client(ctx context.Context, followRedirects bool) (*http.Client, error)
Client returns an authenticated OAuth http client
func (*OAuthSessionManager) ReAuthenticate ¶
func (m *OAuthSessionManager) ReAuthenticate(ctx context.Context) error
ReAuthenticate causes a new http.Client to be created with new a new authentication context, likely in response to a 401
This won't work for userTokenAuth since we have no credentials to exchange for a new token.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is used to help build up an HTTP request
func NewRequest ¶
NewRequest creates a new minimally configured HTTP request instance
func (*Request) WithBody ¶
WithBody adds the specified body as-is to the request and defaults the content type to JSON
func (*Request) WithContentLength ¶
WithContentLength sets the content length, needed for file uploads
func (*Request) WithContentType ¶
WithContentType sets the content type of the request body
func (*Request) WithFollowRedirects ¶
WithFollowRedirects sets the content type of the request body
func (*Request) WithHeader ¶
WithHeader sets an arbitrary header on the request
func (*Request) WithObject ¶
WithObject adds an object to the request body to be JSON serialized
type UnauthenticatedClientProvider ¶
type UnauthenticatedClientProvider struct {
// contains filtered or unexported fields
}
func NewUnauthenticatedClientProvider ¶
func NewUnauthenticatedClientProvider(httpClient *http.Client) *UnauthenticatedClientProvider
func (*UnauthenticatedClientProvider) ReAuthenticate ¶
func (c *UnauthenticatedClientProvider) ReAuthenticate(ctx context.Context) error