@@ -10,7 +10,6 @@ import (
1010 "encoding/json"
1111 "fmt"
1212 "io"
13- "net/http"
1413 nethttp "net/http"
1514 "reflect"
1615 "strings"
@@ -43,9 +42,9 @@ type Action struct {
4342// runtime error.
4443func (a * Action ) Do (
4544 ctx context.Context ,
46- c * http .Client ,
45+ c * nethttp .Client ,
4746 defaults * Defaults ,
48- ) (* http .Response , error ) {
47+ ) (* nethttp .Response , error ) {
4948 url , err := a .getURL (ctx , defaults )
5049 if err != nil {
5150 return nil , err
@@ -54,7 +53,9 @@ func (a *Action) Do(
5453 debug .Printf (ctx , "http: > %s %s" , a .Method , url )
5554 var reqData io.Reader
5655 if a .Data != nil {
57- a .processRequestData (ctx )
56+ if err := a .processRequestData (ctx ); err != nil {
57+ return nil , err
58+ }
5859 jsonBody , err := json .Marshal (a .Data )
5960 if err != nil {
6061 return nil , err
@@ -63,7 +64,7 @@ func (a *Action) Do(
6364 if b .Size () > 0 {
6465 sendData , _ := io .ReadAll (b )
6566 debug .Printf (ctx , "http: > %s" , sendData )
66- b .Seek (0 , 0 )
67+ b .Seek (0 , 0 ) // nolint:errcheck
6768 }
6869 reqData = b
6970 }
@@ -109,9 +110,9 @@ func (a *Action) getURL(
109110// expressions. If we find any, we query the fixture registry to see if any
110111// fixtures have a value that matches the JSONPath expression. See
111112// gdt.fixtures:jsonFixture for more information on how this works
112- func (a * Action ) processRequestData (ctx context.Context ) {
113+ func (a * Action ) processRequestData (ctx context.Context ) error {
113114 if a .Data == nil {
114- return
115+ return nil
115116 }
116117 // Get a pointer to the unmarshaled interface{} so we can mutate the
117118 // contents pointed to
@@ -127,11 +128,18 @@ func (a *Action) processRequestData(ctx context.Context) {
127128 for i := 0 ; i < v .Len (); i ++ {
128129 item := v .Index (i ).Elem ()
129130 it := item .Type ()
130- a .preprocessMap (ctx , item , it .Key (), it .Elem ())
131+ err := a .preprocessMap (ctx , item , it .Key (), it .Elem ())
132+ if err != nil {
133+ return err
134+ }
131135 }
132136 case reflect .Map :
133- a .preprocessMap (ctx , v , vt .Key (), vt .Elem ())
137+ err := a .preprocessMap (ctx , v , vt .Key (), vt .Elem ())
138+ if err != nil {
139+ return err
140+ }
134141 }
142+ return nil
135143}
136144
137145// processRequestDataMap processes a map pointed to by v, transforming any
0 commit comments