Code improvement#9
Conversation
| #include "error.hpp" | ||
|
|
||
| // internal TRequest | ||
| #include "TRequest.hpp" |
There was a problem hiding this comment.
I though I'm clever but now I see I'm not. I can't figure out what means T in TRequest.hpp :). I would rename it to "two word name" T....Request.hpp.
There was a problem hiding this comment.
Sorry for it. It is just my way to define class, so then we can instance with the name of the object. So in this case it is TRequest so then we can do:
TRequest Request = new TRequest();
Request.get(...);So in my mind T is Template like a way to call the recipe of abstraction (class) of the object (instance). But of course we can name it as you prefer.
There was a problem hiding this comment.
I was looking in TRequests.hpp and I would rename all occurrences of TRequest to HTTPRequest which will improve code clarity.
There was a problem hiding this comment.
@MMquant sorry for the delay. I will change as soon as I have a moment.
There was a problem hiding this comment.
I'll change to HTTPRequest even if the request is not limited to the HTTP protocol.
app/include/bfx-api-cpp/TRequest.hpp
Outdated
| //////////////////////////////////////////////////////////////////////// | ||
| // Private properties | ||
| //////////////////////////////////////////////////////////////////////// | ||
| string endpoint = ""; |
There was a problem hiding this comment.
I think string initialization string endpoint = ""; is unnecessary. Simple less verbose string endpoint; should do the same.
(1) empty string constructor (default constructor)
Constructs an empty string, with a length of zero characters.
app/include/bfx-api-cpp/TRequest.hpp
Outdated
| void setupHeader() { | ||
| curlHeader = nullptr; | ||
| map<string, string>::iterator it; | ||
| for (it = header.begin(); it != header.end(); it++) { |
There was a problem hiding this comment.
Couldn't this code be simplified such ...
delete map<string, string>::iterator it;
change for (auto it = header.begin(); it != header.end(); ++it) {
?
But it's up to you if you prefer more verbose way. auto keyword comes handy in these cases.
* Removing not needed files. * Moving project source into app folder. * Adding docker files for alpine distro. * Updating README.md. * Updating git ignore. * Code improvement (#9) * Removing not needed files. * Moving project source into app folder. * Adding docker files for alpine distro. * Adding test. * Moving all the curl calls and settings to the Request object. * Formatting header. * Making key-secret file optional. * circleci fix
Change log
Requestobject.Motivation
Creating the first test file.
Reducing code lines from
BitfinexAPI.hppand cleaning it moving thecurl handlersto theRequestclass.Using a small docker image.
Using docker-compose to sync the app folder and its content between the docker image and the host machine.
Avoiding clone the project inside the docker image.
Separating the project file from the docker files.
TODO
Test the
postaction.