internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RWLockToggle

func RWLockToggle(mu *sync.RWMutex) (func(), func())

RWLockToggle locks the given mutex for reading and returns two functions the first function returned should be used to unlock the mutex the second function returned will unlock the read lock and instead lock the mutex for writing the unlock function will always call the correct unlock method

Types

type Client

type Client struct {
	L      log.FieldLogger
	Region api.Region
	APIKey string
	Client Doer
}

Client provides methods for communication with the Riot API.

func NewClient

func NewClient(region api.Region, key string, client Doer, logger log.FieldLogger) *Client

NewClient returns a new client.

func (*Client) DoRequest

func (c *Client) DoRequest(method, endpoint string, body io.Reader) (*http.Response, error)

DoRequest processes a http.Request and returns the response. Rate-Limiting and retrying is handled via the corresponding response headers.

func (*Client) Get

func (c *Client) Get(endpoint string) (*http.Response, error)

Get processes a GET request.

func (*Client) GetInto

func (c *Client) GetInto(endpoint string, target interface{}) error

GetInto processes a GET request and saves the response body into the given target.

func (*Client) Logger

func (c *Client) Logger() log.FieldLogger

Logger returns a logger with client specific fields set.

func (*Client) NewRequest

func (c *Client) NewRequest(method, endpoint string, body io.Reader) (*http.Request, error)

NewRequest returns a new http.Request with necessary headers et.

func (*Client) Post

func (c *Client) Post(endpoint string, body interface{}) (*http.Response, error)

Post processes a POST request.

func (*Client) PostInto

func (c *Client) PostInto(endpoint string, body, target interface{}) error

PostInto processes a POST request and saves the response body into the given target.

func (*Client) Put

func (c *Client) Put(endpoint string, body interface{}) error

Put processes a PUT request.

type Doer

type Doer interface {
	// Do processes an HTTP request and returns the response
	Do(r *http.Request) (*http.Response, error)
}

Doer is an interface for any client that can process an HTTP request and return a response. This will most commonly be a simple HTTP client.

Directories

Path Synopsis
Package mock includes mock constructs used for testing the API.
Package mock includes mock constructs used for testing the API.

Jump to

Keyboard shortcuts

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