@@ -59,15 +59,15 @@ func decodeJSONBody(req *http.Request, dest interface{}) error {
5959}
6060
6161func StringResponse (body string ) Responder {
62- return func (* http.Request ) (* http.Response , error ) {
63- return httpResponse (200 , bytes .NewBufferString (body )), nil
62+ return func (req * http.Request ) (* http.Response , error ) {
63+ return httpResponse (200 , req , bytes .NewBufferString (body )), nil
6464 }
6565}
6666
6767func JSONResponse (body interface {}) Responder {
68- return func (* http.Request ) (* http.Response , error ) {
68+ return func (req * http.Request ) (* http.Response , error ) {
6969 b , _ := json .Marshal (body )
70- return httpResponse (200 , bytes .NewBuffer (b )), nil
70+ return httpResponse (200 , req , bytes .NewBuffer (b )), nil
7171 }
7272}
7373
@@ -84,7 +84,7 @@ func GraphQLMutation(body string, cb func(map[string]interface{})) Responder {
8484 }
8585 cb (bodyData .Variables .Input )
8686
87- return httpResponse (200 , bytes .NewBufferString (body )), nil
87+ return httpResponse (200 , req , bytes .NewBufferString (body )), nil
8888 }
8989}
9090
@@ -100,13 +100,14 @@ func GraphQLQuery(body string, cb func(string, map[string]interface{})) Responde
100100 }
101101 cb (bodyData .Query , bodyData .Variables )
102102
103- return httpResponse (200 , bytes .NewBufferString (body )), nil
103+ return httpResponse (200 , req , bytes .NewBufferString (body )), nil
104104 }
105105}
106106
107- func httpResponse (status int , body io.Reader ) * http.Response {
107+ func httpResponse (status int , req * http. Request , body io.Reader ) * http.Response {
108108 return & http.Response {
109109 StatusCode : status ,
110+ Request : req ,
110111 Body : ioutil .NopCloser (body ),
111112 }
112113}
0 commit comments