Skip to content

add `api.Client` API communication methods

Ava Howell requested to merge avahowell:api-client into master

This PR adds api.Client, an interface for communicating with a Sia API. It handles creating the request with the proper user agent and url, basic authentication, and decoding. Here's an example usage:

c := api.NewClient("localhost:9980", "")
var gatewayInfo api.GatewayGET
err := c.Get("/gateway", &gatewayInfo)
if err != nil {
   // handle this error
}
fmt.Println(gatewayInfo)

this should provide a more elegant and easy-to-grok interface for Golang devs to use when they use the Sia API.

Merge request reports