Major refactor and API changes

- Updated `.gitignore` file
- Updated `CMakeLists.txt` to build static exectuable
- Changed some `Doxyfile` configurations to build more robust and complete documentation (WIP)
- Changed how `remote` works to better reflect `git`'s API (WIP)
- Changed how error handling works
- Improved `bin/compile.sh` script
- Improved `bin/lines.sh` script (kinda)
- Removed some instances of `fmt` in favor of `std` string functions
- Restructed style for better readibility
This commit is contained in:
David Allen 2023-05-22 17:54:45 -06:00
parent ba23299777
commit 5a73651ad1
29 changed files with 1836 additions and 1140 deletions

View file

@ -1,18 +1,31 @@
#pragma once
#include "constants.hpp"
#include "types.hpp"
#include <unordered_map>
namespace gdpm::http{
using headers_t = std::unordered_map<string, string>;
enum response_code{
OK = 200,
NOT_FOUND = 400
};
struct response{
long code = 0;
std::string body{};
std::unordered_map<std::string, std::string> headers{};
string body{};
headers_t headers{};
error error();
};
response request_get(const std::string& url, size_t timeout = GDPM_CONFIG_TIMEOUT_MS, int verbose = 0);
response request_post(const std::string& url, const char *post_fields="", size_t timeout = GDPM_CONFIG_TIMEOUT_MS, int verbose = 0);
response download_file(const std::string& url, const std::string& storage_path, size_t timeout = GDPM_CONFIG_TIMEOUT_MS, int verbose = 0);
struct params {
size_t timeout = GDPM_CONFIG_TIMEOUT_MS;
int verbose = 0;
};
string url_escape(const string& url);
response request_get(const string& url, const http::params& params = http::params());
response request_post(const string& url, const char *post_fields="", const http::params& params = http::params());
response download_file(const string& url, const string& storage_path, const http::params& params = http::params());
}