feat: add NewJsonResponseOrPanic function to simplify calls with ResponderFromMultipleResponses#151
Conversation
maxatome
left a comment
There was a problem hiding this comment.
Thanks for your PR. See my comments to go further.
Just as a note did you know that you can chain Responder using Then method? It appeared after ResponderFromMultipleResponses implementation. Using it you can do:
responder := httpmock.NewJsonResponderOrPanic(200, x).
Then(httpmock.NewJsonResponderOrPanic(200, y)).
Then(httpmock.NewJsonResponderOrPanic(200, z))|
Could you please also change the commit message to: |
Hi, yes I did see this builder function. We've been using it for the last two days, it's great too ! But I still think that |
Will do ! |
Simplify calls to
ResponderFromMultipleResponsesfor JSON body responses withNewJsonResponseOrPanic.Just as the same as
NewJsonResponderOrPanicandNewJsonResponder, it's an addition to simplify some calls and avoid local variables with error handling.