workgroups/vendor/github.com/dghubble/sling/response.go
Marvin Preuss 1d4ae27878
All checks were successful
continuous-integration/drone/push Build is passing
ci: drone yaml with reusable anchors
2021-09-24 17:34:17 +02:00

23 lines
619 B
Go

package sling
import (
"encoding/json"
"net/http"
)
// ResponseDecoder decodes http responses into struct values.
type ResponseDecoder interface {
// Decode decodes the response into the value pointed to by v.
Decode(resp *http.Response, v interface{}) error
}
// jsonDecoder decodes http response JSON into a JSON-tagged struct value.
type jsonDecoder struct {
}
// Decode decodes the Response Body into the value pointed to by v.
// Caller must provide a non-nil v and close the resp.Body.
func (d jsonDecoder) Decode(resp *http.Response, v interface{}) error {
return json.NewDecoder(resp.Body).Decode(v)
}