New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup httpmock #29
Cleanup httpmock #29
Conversation
|
||
type Matcher func(req *http.Request) bool | ||
|
||
func REST(method, p string) Matcher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we think about the naming scheme here? Should we prefix/postfix Match
/Matcher
to this and the GQL
function?
stubs []*stub | ||
requests []*http.Request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I purposefully un-exported these and added a Requests()
accessor function. It felt smart to move this direction incase we want to change the underlying implementation.
} | ||
if stub != nil { | ||
r.mu.Unlock() | ||
dr, _ := httputil.DumpRequestOut(req, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using DumpRequestOut
leads to nicer looking error messages.
|
||
type Responder func(req *http.Request) (*http.Response, error) | ||
|
||
func HTTPResponse(status int, header *map[string][]string, body interface{}, cb func(*http.Request)) Responder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we think about the naming scheme for Responders? Should we prefix/postfix them with Response
/Responder
?
} | ||
} | ||
|
||
func RESTResponse(body interface{}, cb func(map[string]interface{})) Responder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having HTTPResponse
and RESTResponse
to be a bit confusing. Open to better naming here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any less confusing if you call RESTResponse
a JSONResponse
? Afterall, it's just the response itself which happens to be JSON. Perhaps HTTPResponse
could be RAWResponse
and uses for non-JSON payloads - perhaps with a content-type? More focus on the payload than how it was retrieved.
Closing as we decided against exporting |
This PR gets the package formerly known as
httpmock
into a state that it can be made public and moved out of theinternal
folder.Some major changes:
transportmock
I left comments for open questions inline.
cc #28