Documentation ¶
Index ¶
- Variables
- func Decode(resp *http.Response) ([]byte, error)
- func EnableJSON() func(*http.Request) error
- func EnableMsgpack() func(*http.Request) error
- func EnableSnappyEncoding() func(*http.Request) error
- func NewSnappyResponseReader(resp *http.Response) io.ReadCloser
- func Unmarshal(resp *http.Response, out interface{}) error
- func WithAPIKey(apiKey string) func(*http.Request) error
- func WithHeader(name, value string) func(*http.Request) error
- func WithHeaders(headers map[string]string) func(*http.Request) error
- func WithNamespace(ns string) func(*http.Request) error
- func WithQueryArg(name, value string) func(*http.Request) error
- func WithQueryArgs(query map[string]string) func(*http.Request) error
- func WithUserAgent(ua string) func(*http.Request) error
- type BadStatusCodeError
- type Caps
- type Client
- func (client *Client) DoReq(ctx context.Context, method, path string, headers map[string]string, ...) (*http.Response, error)
- func (client *Client) DoReqWithQuery(ctx context.Context, method, path string, query map[string]string, ...) (*http.Response, error)
- func (client *Client) GetJSON(ctx context.Context, path string, headers map[string]string, out interface{}) error
- func (client *Client) Opts() *Opts
- func (client *Client) SessionID() string
- type ClientUtil
- func (client *ClientUtil) Capabilities() (*Caps, error)
- func (client *ClientUtil) CheckAuth() (bool, error)
- func (client *ClientUtil) Delete(path string, options ...func(*http.Request) error) (*http.Response, error)
- func (client *ClientUtil) Do(method, path string, body io.Reader, options ...func(*http.Request) error) (*http.Response, error)
- func (client *ClientUtil) Get(path string, options ...func(*http.Request) error) (*http.Response, error)
- func (client *ClientUtil) Head(path string, options ...func(*http.Request) error) (*http.Response, error)
- func (client *ClientUtil) PatchJSON(path string, payload interface{}, options ...func(*http.Request) error) (*http.Response, error)
- func (client *ClientUtil) PatchMsgpack(path string, payload interface{}, options ...func(*http.Request) error) (*http.Response, error)
- func (client *ClientUtil) Post(path string, data []byte, options ...func(*http.Request) error) (*http.Response, error)
- func (client *ClientUtil) PostJSON(path string, payload interface{}, options ...func(*http.Request) error) (*http.Response, error)
- func (client *ClientUtil) PostMsgpack(path string, payload interface{}, options ...func(*http.Request) error) (*http.Response, error)
- type Opts
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBlobNotFound = errors.New("blob not found")
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
func EnableJSON ¶
func EnableMsgpack ¶
func EnableSnappyEncoding ¶
func NewSnappyResponseReader ¶
func NewSnappyResponseReader(resp *http.Response) io.ReadCloser
Types ¶
type BadStatusCodeError ¶
type BadStatusCodeError struct { Expected int ResponseStatusCode int ResponseBody []byte RequestMethod string RequestURL string // In case it failed before getting the response Err error }
func ExpectStatusCode ¶
func ExpectStatusCode(resp *http.Response, status int) *BadStatusCodeError
func (*BadStatusCodeError) Error ¶
func (e *BadStatusCodeError) Error() string
func (*BadStatusCodeError) IsNotFound ¶
func (e *BadStatusCodeError) IsNotFound() (res bool)
func (*BadStatusCodeError) IsUnauthorized ¶
func (e *BadStatusCodeError) IsUnauthorized() (res bool)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DoReq ¶
func (client *Client) DoReq(ctx context.Context, method, path string, headers map[string]string, body io.Reader) (*http.Response, error)
DoReq "do" the request and returns the `*http.Response`
func (*Client) DoReqWithQuery ¶
func (client *Client) DoReqWithQuery(ctx context.Context, method, path string, query map[string]string, headers map[string]string, body io.Reader) (*http.Response, error)
DoReq "do" the request and returns the `*http.Response`
type ClientUtil ¶
type ClientUtil struct {
// contains filtered or unexported fields
}
func NewClientUtil ¶
func NewClientUtil(host string, options ...func(*http.Request) error) *ClientUtil
New initializes an HTTP client
func (*ClientUtil) Capabilities ¶
func (client *ClientUtil) Capabilities() (*Caps, error)
func (*ClientUtil) CheckAuth ¶
func (client *ClientUtil) CheckAuth() (bool, error)
func (*ClientUtil) Do ¶
func (client *ClientUtil) Do(method, path string, body io.Reader, options ...func(*http.Request) error) (*http.Response, error)
DoReq "do" the request and returns the `*http.Response`
func (*ClientUtil) PatchMsgpack ¶
func (*ClientUtil) PostMsgpack ¶
type Opts ¶
type Opts struct { Host string // BlobStash host (with proto and without trailing slash) e.g. "https://blobtash.com" APIKey string // BlobStash API key Namespace string // BlobStash namespace Headers map[string]string // Headers added to each request UserAgent string // Custom User-Agent SnappyCompression bool // Enable snappy compression for the HTTP requests }
Opts holds the client configuration
func (*Opts) SetHost ¶
SetHost is a configuration shortcut for setting the API hostname and the API key
func (*Opts) SetNamespace ¶
SetNamespace is a shortcut for setting the namespace at the client level
Click to show internal directories.
Click to hide internal directories.