method to build a HTTP request (*http.Request) • Define a method to make the actual HTTP request and handle its response いい感 じに • Use above stuffs from the service struct’s methods that correspond 1-to-1 with the actual API endpoints Steps to Make It せやかて
Client has some methods for building HTTP request, invoking actual API, etc In my (and some other library’s) design, it constructs with the various services to access different parts of the API type Client struct {}
newRequest creates an API request with proper headers and serializations. // If v is supplied, the value will be JSON encoded and included as the request body. // If the method is GET, it will be query parameters instead. Ref: https://github.com/grezar/go-circleci/blob/c8fca9c02dd337074caeec2515c8f97635597c57/circleci.go#L115-L165
invokes an actual API using req and if v is supplied, fill it with with the API // response deserialized. // It returns error instead, if it gets an error from the API. Ref: https://github.com/grezar/go-circleci/blob/c8fca9c02dd337074caeec2515c8f97635597c57/circleci.go#L167-L2 04