Documentation ¶
Index ¶
- type JSONClient
- func (c *JSONClient) GetAndParse(ctx context.Context, path string, params map[string]string, rsp interface{}) (*http.Response, error)
- func (c *JSONClient) PostAndParse(ctx context.Context, path string, req, rsp interface{}) (*http.Response, error)
- func (c *JSONClient) PostAndParseWithRetry(ctx context.Context, path string, req, rsp interface{}) (*http.Response, error)
- type Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONClient ¶
type JSONClient struct { Verifier *ct.SignatureVerifier // nil for no verification (e.g. no public key available) // contains filtered or unexported fields }
JSONClient provides common functionality for interacting with a JSON server that uses cryptographic signatures.
func New ¶
New constructs a new JSONClient instance, for the given base URI, using the given http.Client object (if provided) and the Options object.
func (*JSONClient) GetAndParse ¶
func (c *JSONClient) GetAndParse(ctx context.Context, path string, params map[string]string, rsp interface{}) (*http.Response, error)
GetAndParse makes a HTTP GET call to the given path, and attempt to parse the response as a JSON representation of the rsp structure. The provided context is used to control the HTTP call.
func (*JSONClient) PostAndParse ¶
func (c *JSONClient) PostAndParse(ctx context.Context, path string, req, rsp interface{}) (*http.Response, error)
PostAndParse makes a HTTP POST call to the given path, including the request parameters, and attempt to parse the response as a JSON representation of the rsp structure. The provided context is used the control the HTTP call.
func (*JSONClient) PostAndParseWithRetry ¶
func (c *JSONClient) PostAndParseWithRetry(ctx context.Context, path string, req, rsp interface{}) (*http.Response, error)
PostAndParseWithRetry makes a HTTP POST call, but retries (with backoff) on retriable errors.
type Logger ¶
type Logger interface { // Printf formats and logs a message Printf(string, ...interface{}) }
Logger is a simple logging interface used to log internal errors and warnings
type Options ¶
type Options struct { // Interface to use for logging warnings and errors, if nil the // standard library log package will be used. Logger Logger // PEM format public key to use for signature verification, if // empty signatures will not be verified. PublicKey string }
Options are the options for creating a new JSONClient.