Skip to content
/ Http Public

A header-only HTTP library based on boost::beast and nlohmann::json

License

Notifications You must be signed in to change notification settings

jfayot/Http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP library

A header-only HTTP library based on boost::beast and nlohmann::json.

Features

  • GET, PUT, POST, PATCH and DELETE resources from/to a REST service
  • HTTP/HTTPS
  • Basic and Bearer token authentication
  • Post FormData (Get FormData not yet implemented)
  • Asynchronous response wrapped into future
  • Upload/Download files

Dependencies

  • Boost::beast
  • OpenSSL
  • nlohmann::json
  • fmt

Build

Use conan to install dependencies:

pip install conan
mkdir build && pushd build && conan install .. && popd
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=./build/conan_path.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build 

Minimal example

#include "Http/HttpTypes.hpp"
struct Person
{
    std::string name;
    int age;

    NLOHMANN_DEFINE_TYPE_INTRUSIVE(Person, name, age)
};

int main()
{
    Person person{ "captain", 42 };
    
    Http::Client client{ "http://127.0.0.1:8080" };

    auto res = client.post("/Persons").body(person).send().get();

    if (true == res.ok()) ...

About

A header-only HTTP library based on boost::beast and nlohmann::json

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages