Notable changes between releases.
- Update minimum Go version to v1.18 (#76)
Do
reads Body to reuse HTTP/1.x "keep-alive" TCP connections (#59)Receive
skips decoding if status is 204 (no content) (#63)
- Add Sling
ResponseDecoder
setter for receiving responses with a customResponseDecoder
(#49) - Add Go module support (i.e.
go.mod
). Excludeexamples
(multi-module). (#52)
- Add
Connect
,Options
, andTrace
HTTP methods (c51967) - Skip receiving (i.e. decoding)
204 No Content
responses (#31)
- Allow JSON decoding, regardless of response Content-Type (#26)
- Add
BodyProvider
interface and setter so request Body encoding can be customized (#23) - Add
Doer
interface and setter so request sending behavior can be customized (#21) - Add
SetBasicAuth
setter for Authorization headers (#16) - Add Sling
Body
setter to set anio.Reader
on the Request (#9)
- Added support for receiving and decoding error JSON structs
- Renamed Sling
JsonBody
setter toBodyJSON
(breaking) - Renamed Sling
BodyStruct
setter toBodyForm
(breaking) - Renamed Sling fields
httpClient
,method
,rawURL
, andheader
to be internal (breaking) - Changed
Do
andReceive
to skip response JSON decoding if "application/json" Content-Type is missing - Changed
Sling.Receive(v interface{})
toSling.Receive(successV, failureV interface{})
(breaking)- Previously
Receive
attempted to decode the response Body in all cases - Updated
Receive
will decode the response Body into successV for 2XX responses or decode the Body into failureV for other status codes. Pass a nilsuccessV
orfailureV
to skip JSON decoding into that value. - To upgrade, pass nil for the
failureV
argument or consider defining a JSON tagged struct appropriate for the API endpoint. (e.g.s.Receive(&issue, nil)
,s.Receive(&issue, &githubError)
) - To retain the old behavior, duplicate the first argument (e.g. s.Receive(&tweet, &tweet))
- Previously
- Changed
Sling.Do(http.Request, v interface{})
toSling.Do(http.Request, successV, failureV interface{})
(breaking)- See the changelog entry about
Receive
, the upgrade path is the same.
- See the changelog entry about
- Removed HEAD, GET, POST, PUT, PATCH, DELETE constants, no reason to export them (breaking)
- Improved golint compliance
- Fixed typos and test printouts
- Added BodyStruct method for setting a url encoded form body on the Request
- Added Add and Set methods for adding or setting Request Headers
- Added JsonBody method for setting JSON Request Body
- Improved examples and documentation
- Added http.Client setter
- Added Sling.New() method to return a copy of a Sling
- Added Base setter and Path extension support
- Added method setters (Get, Post, Put, Patch, Delete, Head)
- Added support for encoding URL Query parameters
- Added example tiny Github API
- Changed v0.1.0 method signatures and names (breaking)
- Removed Go 1.0 support
- Support decoding JSON responses.