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.
Hey @derekkraan, Merry Christmas! 🎁
I've got a pretty big present for you! 😄
the past few weeks i was working on this refactoring. There are no changes to the public API..just some Bugfixes and ordering of the CLI flags of cURL have been changed. Our test suite ist still the same with the same public functions.
The most important bit is the new module
CurlReq.Request
where we define a generic struct and helper function to modify that struct to represent a generic HTTP request. It also defines a behaviour (encode/2
,decode/2
) which the Curl and Req modules implement. They are just a refactor from the Main and Macro module.The biggest benefit of this change would be, to set us up nicely to generate cURL commands from other HTTP clients. We would've just have to implement the behaviours and parse the request struct into our generic request struct.
Further, we seperate the cURL representation from the req representation which makes parsing so much easier because we don't have to think about req internals when parsing the cURL string and the other way round.
This makes processing the information simple, like getting auth or encoding information from the parsed headers and storing them in different field in the CurlReq.Request struct instead of just the generic header.
Also this refactoring found some existing bugs and added some enhancements. It is best schon in the following test:
BEFORE:
AFTER:
I have some minor TODOs but i wanted to show you this PR and get some early thought on it
Closes #25