Documentation ¶
Overview ¶
Package httpclient includes a wrapped http client for easier data access
Index ¶
- Variables
- func NonSensitiveHeaders(h http.Header) http.Header
- type Doer
- type HTTPClient
- func (c *HTTPClient) Get(ctx context.Context, url string, headers *http.Header) (*http.Response, error)
- func (c *HTTPClient) GetBody(ctx context.Context, url string, headers *http.Header) (*http.Response, []byte, error)
- func (c *HTTPClient) GetJSON(ctx context.Context, url string, headers *http.Header, t interface{}) (*http.Response, error)
- func (c *HTTPClient) Post(ctx context.Context, url string, headers *http.Header, body io.Reader) (*http.Response, error)
- func (c *HTTPClient) PostBody(ctx context.Context, url string, headers *http.Header, body io.Reader) (*http.Response, []byte, error)
- func (c *HTTPClient) PostJSON(ctx context.Context, url string, headers *http.Header, body io.Reader, ...) (*http.Response, error)
- func (c *HTTPClient) Put(ctx context.Context, url string, headers *http.Header, body io.Reader) (*http.Response, error)
- func (c *HTTPClient) PutBody(ctx context.Context, url string, headers *http.Header, body io.Reader) (*http.Response, []byte, error)
- func (c *HTTPClient) PutJSON(ctx context.Context, url string, headers *http.Header, body io.Reader, ...) (*http.Response, error)
- func (c *HTTPClient) SetDebug(val bool)
- func (c *HTTPClient) SetHeaders(h http.Header)
- type Logger
- type RateLimit
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
var ErrResponse = errors.New("error response")
ErrResponse is the error that is wrapped and returned when there is a non-200 api response
Functions ¶
Types ¶
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is a wrapped http client for interacting with discord
func NewHTTPClient ¶
func NewHTTPClient(deps dependencies) *HTTPClient
NewHTTPClient creates a new http client
func (*HTTPClient) Get ¶
func (c *HTTPClient) Get(ctx context.Context, url string, headers *http.Header) (*http.Response, error)
Get performs an http GET
func (*HTTPClient) GetBody ¶
func (c *HTTPClient) GetBody(ctx context.Context, url string, headers *http.Header) (*http.Response, []byte, error)
GetBody performs an http GET an returns the response body
func (*HTTPClient) GetJSON ¶
func (c *HTTPClient) GetJSON(ctx context.Context, url string, headers *http.Header, t interface{}) (*http.Response, error)
GetJSON performs an http GET and unmarshals the response body into the provided target
func (*HTTPClient) Post ¶
func (c *HTTPClient) Post(ctx context.Context, url string, headers *http.Header, body io.Reader) (*http.Response, error)
Post performs an http POST
func (*HTTPClient) PostBody ¶
func (c *HTTPClient) PostBody(ctx context.Context, url string, headers *http.Header, body io.Reader) (*http.Response, []byte, error)
PostBody performs an http POST and returns the response body
func (*HTTPClient) PostJSON ¶
func (c *HTTPClient) PostJSON(ctx context.Context, url string, headers *http.Header, body io.Reader, t interface{}) (*http.Response, error)
PostJSON performs an http POST and unmarshals the response body into the provided target
func (*HTTPClient) Put ¶
func (c *HTTPClient) Put(ctx context.Context, url string, headers *http.Header, body io.Reader) (*http.Response, error)
Put performs an http PUT
func (*HTTPClient) PutBody ¶
func (c *HTTPClient) PutBody(ctx context.Context, url string, headers *http.Header, body io.Reader) (*http.Response, []byte, error)
PutBody performs an http PUT and returns the response body
func (*HTTPClient) PutJSON ¶
func (c *HTTPClient) PutJSON(ctx context.Context, url string, headers *http.Header, body io.Reader, t interface{}) (*http.Response, error)
PutJSON performs an http PUT and unmarshals the response body into the provided target
func (*HTTPClient) SetDebug ¶
func (c *HTTPClient) SetDebug(val bool)
SetDebug turns on/off debug mode
func (*HTTPClient) SetHeaders ¶
func (c *HTTPClient) SetHeaders(h http.Header)
SetHeaders adds the provided headers to the set to be included in all requests
type Logger ¶
type Logger = interface { Log(keyvals ...interface{}) error Message(string, ...interface{}) Err(string, error, ...interface{}) Printf(string, ...interface{}) }
Logger is the interface expected for logging
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter is a rate limiting feature that accepts outside input dynamically for limits per time