apiclient

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 14 Imported by: 3

README

apiclient

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	BaseURL              *url.URL
	CacheDirectory       string
	MaxCacheTime         time.Duration
	MaxRequestsPerSecond float64
	Authenticator        Authenticator
	// contains filtered or unexported fields
}

func NewAPIClient

func NewAPIClient(opts APIClientOptions) (*APIClient, error)

func (*APIClient) Client

func (c *APIClient) Client() *HTTPClient

func (*APIClient) Do

func (c *APIClient) Do(req *http.Request) (*http.Response, error)

func (*APIClient) Get

func (c *APIClient) Get(rsrc string, args url.Values) (*http.Response, error)

func (*APIClient) GetObj

func (c *APIClient) GetObj(rsrc string, args url.Values, obj interface{}) error

type APIClientOptions

type APIClientOptions struct {
	BaseURL              string
	RequestTimeout       time.Duration
	CacheStore           cache.CacheStore
	MaxCacheTime         time.Duration
	MaxRequestsPerSecond float64
	Auth                 Authenticator
}

type Authenticator

type Authenticator interface {
	AuthenticateRequest(req *http.Request) error
}

type BasicAuth

type BasicAuth struct {
	// contains filtered or unexported fields
}

func NewBasicAuth

func NewBasicAuth(user, pwd string) *BasicAuth

func (*BasicAuth) AuthenticateRequest

func (a *BasicAuth) AuthenticateRequest(req *http.Request) error

type BearerAuth

type BearerAuth string

func NewBearerAuth

func NewBearerAuth(token string) *BearerAuth

func (*BearerAuth) AuthenticateRequest

func (a *BearerAuth) AuthenticateRequest(req *http.Request) error

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(opts APIClientOptions) (*HTTPClient, error)

func (*HTTPClient) Do

func (c *HTTPClient) Do(req *http.Request) (*http.Response, error)

func (*HTTPClient) Get

func (c *HTTPClient) Get(u string) (*http.Response, error)

type QueryArgAuth

type QueryArgAuth struct {
	// contains filtered or unexported fields
}

func NewQueryArgAuth

func NewQueryArgAuth(arg, key string) *QueryArgAuth

func (*QueryArgAuth) AuthenticateRequest

func (a *QueryArgAuth) AuthenticateRequest(req *http.Request) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL