Documentation
¶
Index ¶
- Variables
- type BaseClient
- func (c BaseClient) Do(req *http.Request) (*http.Response, error)
- func (c BaseClient) Get(ctx context.Context, endpoint string) (*http.Response, error)
- func (c BaseClient) NewRequestWithContext(ctx context.Context, method, endpoint string, body io.Reader) (*http.Request, error)
- func (c BaseClient) NewURL(endpoint string) (*url.URL, error)
- type Client
- type Dofn
- type Middleware
- type ParseError
Constants ¶
This section is empty.
Variables ¶
var Warning = errors.New("warning")
this can be users to indicate errors that are more like warning and should be logged, but should not stop execution flow.
Functions ¶
This section is empty.
Types ¶
type BaseClient ¶
type BaseClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(host, baseEndpoint string, timeout time.Duration, doers ...Middleware) *BaseClient
NewClient creates a new BaseClient The (optional) Middleware Do funcs will run in sequence when the Do func is called with a request. The baseEndpoint is not added automatically with Do or Get etc... It is added in if you use the BaseClient.NewURL to generate your new URL. This allows the client to be used with or without assuming the base part. This is useful if you are using the "links" part of responses which already have the base part in them.
func (BaseClient) Get ¶
Get is similar to http.Client{}.Get except it uses the BearerTokenClient and defaults to JSON as the payload to and from the server.
func (BaseClient) NewRequestWithContext ¶
func (c BaseClient) NewRequestWithContext(ctx context.Context, method, endpoint string, body io.Reader) (*http.Request, error)
NewRequestWithContext wraps the http version and sets the url. This allows the endpoint being passed to not include the host or base part of the url.
type Middleware ¶
type ParseError ¶
func (ParseError) Error ¶
func (pe ParseError) Error() string