refactoring
[src/app-framework-binder.git] / plugins / samples / SamplePost.c
index 8894973..d29fb05 100644 (file)
 
 #include "local-def.h"
 
+// Sample Generic Ping Debug API
+static json_object* getPingTest(AFB_request *request) {
+    static int pingcount = 0;
+    json_object *response;
+    char query  [256];
+    char session[256];
+    int len;
+    
+    // request all query key/value
+    len = getQueryAll (request, query, sizeof(query));
+    if (len == 0) strncpy (query, "NoSearchQueryList", sizeof(query));
+    
+    // check if we have some post data
+    if (request->post == NULL)  request->post->data="NoData"; 
+          
+    // return response to caller
+    response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon count=%d uuid=%s query={%s} session={0x%x} PostData: [%s] "
+               , pingcount++, request->uuid, query, session, request->post->data);
+    return (response);
+}
+
 // With content-type=json data are directly avaliable in request->post->data
 STATIC json_object* GetJsonByPost (AFB_request *request) {
     json_object* jresp;
@@ -102,7 +123,6 @@ PUBLIC AFB_plugin *pluginRegister () {
     plugin->info  = "Sample with Post Upload Files";
     plugin->prefix= "post";  // url base
     plugin->apis  = pluginApis;
-    plugin->handle= (void*) "What ever you want";
     
     return (plugin);
 };