Skip to content
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

Refactor HTTP interface #15

Merged
merged 15 commits into from
Jun 10, 2022
Merged

Refactor HTTP interface #15

merged 15 commits into from
Jun 10, 2022

Conversation

brenocq
Copy link
Owner

@brenocq brenocq commented Jun 10, 2022

Description

This pull-request is related to the issue #14. The goal is to refator the atta::io::http. Previouslly, it was causing problems to build to Windows/MacOS/Web. We decided to switch from cpprestsdk to curlpp, which was proven to be easier to build and use.

Current implementation can only do blocking request, but may be extended in the future to support non-blocking requests.

A JSON parser/dumper was also implemented to help dealing with JSON strings.

Http implementation

Now it is only possible to do GET, POST, and PUT requests.

Http::Response Http::get(const Http::Request& req);
Http::Response Http::post(const Http::Request& req);
Http::Response Http::put(const Http::Request& req);

The Request and Response definitions are:

struct Request     
{
    std::map<std::string, std::string> headers;
    std::map<std::string, std::string> params;
    std::string body;
};
struct Response     
{
    unsigned statusCode;
    std::map<std::string, std::string> headers;
    std::string body;
};

JSON implementation

The implementation is similar to Section helper implemented in #13. Examples of how to use the JSON parser/dumper can be found in the JSON unit test file.

@brenocq brenocq added this to the 0.0.4.0 milestone Jun 10, 2022
@brenocq brenocq linked an issue Jun 10, 2022 that may be closed by this pull request
5 tasks
@brenocq brenocq merged commit 33025c4 into master Jun 10, 2022
@brenocq brenocq deleted the refeat-http branch June 10, 2022 20:18
@brenocq brenocq added the status:done Task completed successfully label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:io IO Module status:done Task completed successfully
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Refeat HTTP interface
1 participant