Documentation ¶
Index ¶
- Constants
- Variables
- type Authenticator
- type Client
- func (c Client) Authenticator(au Authenticator) Client
- func (c Client) BaseURL(url string) Client
- func (c Client) Decoder(decoder DecoderGenerator) Client
- func (c Client) Encoder(encoder Encoder) Client
- func (c Client) HTTPClient(client http.Client) Client
- func (c Client) Header(key, value string) Client
- func (c Client) Host(value string) Client
- func (c Client) Pointer() *Client
- func (c Client) Send(ctx context.Context, route, method string, body, responsePtr interface{}) (err error)
- func (c Client) Token(token []byte) Client
- type Decoder
- type DecoderGenerator
- type Encoder
Constants ¶
const ( // DefaultHost is the the standard hostname, it is used in requests made by // the cli to the insprd/uidp services in the cluster DefaultHost = "inspr.com" )
Variables ¶
var ( // DefaultErr is the error returned by the request's response when an // unexpected http.Status is provided and it doesn't have an error structure // in its response body. DefaultErr = ierrors. New("cannot retrieve error from server"). InternalServer() )
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
Authenticator is an interface to perform authentication via tokens
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a generic rest client
func NewJSONClient ¶
NewJSONClient returns a client for the given url with json encoding and decoding
func (Client) Authenticator ¶
func (c Client) Authenticator(au Authenticator) Client
Authenticator adds the authentication interface implementation to the Client structure.
func (Client) Decoder ¶
func (c Client) Decoder(decoder DecoderGenerator) Client
Decoder sets the decoder for the client structure
func (Client) HTTPClient ¶
HTTPClient sets the http client for the client that is being built
func (Client) Header ¶
Header adds the value into the slice located by the key in the client's header map.
func (Client) Send ¶
func (c Client) Send(ctx context.Context, route, method string, body, responsePtr interface{}) (err error)
Send sends a request to the url specified in instantiation, with the given route and method, using the encoder to encode the body and the decoder to decode the response into the responsePtr
type Decoder ¶
type Decoder interface{ Decode(interface{}) error }
Decoder is an interface that decodes a reader into an struct
func JSONDecoderGenerator ¶
JSONDecoderGenerator generates a decoder for json encoded requests
type DecoderGenerator ¶
DecoderGenerator creates a decoder for a given request