Codebase list golang-github-dghubble-sling / b195d729-6acb-49c6-a1c9-9aad21773436/upstream response.go
b195d729-6acb-49c6-a1c9-9aad21773436/upstream

Tree @b195d729-6acb-49c6-a1c9-9aad21773436/upstream (Download .tar.gz)

response.go @b195d729-6acb-49c6-a1c9-9aad21773436/upstreamraw · history · blame

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)
}