Skip to content

nikachu2012/HttpCall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HttpCall

how to use?

Please see examples/HttpCallExample/HttpCallExample.ino.

  1. include and construct

    #include <httpcall.hpp>
    #include <WiFi.h>
    #include <ArduinoJson.h>
    
    // construct
    HttpCall httpcall;
  2. begin

    void setup(void) {
        // ...
        WiFi.begin("your ssid", "your wifi password");
    
        httpcall.begin();
        // ...
    }
  3. add function

    void setup(void) {
        // ...
        httpcall.begin();
        
        //           id      function   value is callback argument
        httpcall.add("test", "test", [](JsonObject j) {
            Serial.println("http called!");
        });
        // ...
    }
  4. handle client

    void loop(void)
    {
        // ...
        httpcall.handleClient();
        // ...
    }
  5. Call function POST method request to http://{your ip}/run.

    Request header is

    {
    "id": "test",
    "function": "test",
    "value": {
        // json
    }
    }

    curl command is

    curl -X POST "http://{your ip with port}/run" \
    -H "Content-Type: application/json" \
    -d '{
    "id": "test",
    "function": "test",
    "value": {
        "foo": bar"
    }
    }'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages