curl-http-wrapper

make http requests easily in c++ ⚡

GPL-3.0 License

Stars
3
Committers
1

prepare, build and run

  sudo make install
  
  make
  
  ./bin/bin

basic struct request

//#include "http/veridic"

 Veridic Url("https://URL");
 
  string data = Url.get();
  
  cout << data;
 

curl-http-wrapper

make http requests easily in c++ using libcurl, contains two modules, raw http and Veridic that wraps the raw giving it even more functions, I recommend using Veridic but if you want you can use raw http but it has certain limitations, such as only making one request per instance which does not happen in Veridic

modules

  • HTTP RAW (wrap curl)
  • VERIDIC (wrap HTTP RAW)

examples

in main or function etc

POST


  Veridic tasty("https://API_name");
  
  POST fields = {
    "name: jhon",
    "lastname: doe"
  }
  
  Headers headers = {
    "data: test",
    "example: true"
  };
    
  tasty.post(fields, headers, "/user");
  tasty.post(fields, "/users");
  tasy.post(fields);
  

GET

Methods

  • POST
  • GET
  • PUT
  • DELETE
  • CUSTM

example get

example put

example delete

example custom

Project and Headers

the structure is very flexible in case you want to use directly the one I put, as long as you add the .cpp code inside the src/sources folder and add it in the makefile like this

  $(DIR_OBJ)/myFile.o
  

FIELDS

the fields are a structure in charge of controlling and preparing the necessary parameters for the requests, they have no limit

Examples

in headers fields, DATA: VALUE

 Headers = {
   "data: 1",
   "data: 2",
   "data: N",
   "N: N",
 };

same that post >>>
 
in POST fields, DATa=value

   POST fields = {
     "uno=1",
     "dos=2",
     "tres=3",
     "N=N"
   };
   
   GET fields = {
     "uno=1",
     "dos=2",
     "tres=3",
     "N=N"
   };
   
   PUT fields = {
     "uno=1",
     "dos=2",
     "tres=3",
     "N=N"
   };
   
   DELETE fields = {
     "uno=1",
     "dos=2",
     "tres=3",
     "N=N"
   };
   

the fields

the fields are the same structure but with a typedef to make the code easier to read, the only difference is the field Headers, which has another structure

other media