Replace 'req' with 'http-client' #8
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
http-clientis kinda a standard for low-level HTTP.reqadds some convenience layer over it, but we mostly don't use that. Moreover, its model rather makes things less transparent and more fragile. E.g. we need direct control over HTTP status codes to handle non-success responses, whatreqobscures (see this thread).servantcould also be an option here, but it is too heavy-weight for this use case.ConnexpayMis also removed. Instead we pass (Config) and return (Response e a) things explicitly. This allows, e.g. to have separate error types for different endpoints. Previously we had single PaymentFailure for all calls, but obviously errors likeCVVFailedcould not be thrown from, say,voidendpoint.Removal of
reqalso reduces dependency footprint, what is good for a public library.Other changes done on the way:
We use neither of its features and all of it is replaced with trivial
USDnewtype.In a public library we should probably use something more flexible than
Text -> IO ()as a logger, but that is a separate storyToJSONinstead of[Pair]Now it is easy to set per-request logger to attach request-specific context to the Connexpay logs