func EncodeBody(i interface{}, cancel context.CancelFunc) (r io.Reader, errFunc func() error) {
	r, w := io.Pipe()
	errChan := make(chan error, 1)
	go func() {
		if err := json.NewEncoder(w).Encode(i); err != nil {
			cancel()
			errChan <- err
		}
		close(errChan)
		w.Close()
	}()
	return r, func() error {
		return <-errChan
	}
}
// EncodeBody JSON encodes i to r. A call to errFunc will block until encoding
// has completed, then return the errur status of the encoding job. If an
// encoding error occurs, cancel() called.
EncodeBody JSON encodes i to r. A call to errFunc will block until encoding
has completed, then return the errur status of the encoding job. If an
encoding error occurs, cancel() called.
// EncodeBody JSON encodes i to r . A call to errFunc will block until encoding // has completed then return the errur status of the encoding job . If an // encoding error occurs cancel () called .
func EncodeBody(i interface{}, cancel context.CancelFunc) (r io.Reader, errFunc func() error) {
	r, w := io.Pipe()
	errChan := make(chan error, 1)
	go func() {
		if err := json.NewEncoder(w).Encode(i); err != nil {
			cancel()
			errChan <- err
		}
		close(errChan)
		w.Close()
	}()
	return r, func() error {
		return <-errChan
	}
}
func EncodeBody ( i interface { } , cancel context . CancelFunc ) ( r io . Reader , errFunc func ( ) error ) { r , w := io . Pipe ( ) errChan := make ( chan error , 1 ) go func ( ) { if err := json . NewEncoder ( w ) . Encode ( i ) ; err != nil { cancel ( ) errChan <- err } close ( errChan ) w . Close ( ) } ( ) return r , func ( ) error { return <- errChan } }
EncodeBody JSON encodes i to r. A call to errFunc will block until encoding
has completed, then return the errur status of the encoding job.
EncodeBody JSON encodes i to r . A call to errFunc will block until encoding has completed then return the errur status of the encoding job .