X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafbs-api.c;h=b55ebf60644852cd8d7aea64be20326bda9168a1;hb=8e61a22b3d7219c59f3925ac8e173b9b74fbcf30;hp=5b7d489626d955730b2b78ce8a5038347fdabc52;hpb=cd054544444e92e7695dd288f0c04b7af0f668e3;p=src%2Fapp-framework-binder.git diff --git a/src/afbs-api.c b/src/afbs-api.c index 5b7d4896..b55ebf60 100644 --- a/src/afbs-api.c +++ b/src/afbs-api.c @@ -19,40 +19,44 @@ #include "local-def.h" -STATIC json_object* pingAfbs (AFB_session *session, AFB_request *request) { - static pingcount=0; + +STATIC json_object* pingSample (AFB_session *session, AFB_request *request, void* handle) { + static pingcount = 0; json_object *response; - const char * argval; + char query [512]; + + // request all query key/value + getQueryAll (request, query, sizeof(query)); - argval=getQueryValue (request, "arg"); - if (argval == NULL) { - argval="No present in query"; - }; + // check if we have some post data + if (request->post == NULL) request->post="NoData"; + + // return response to caller + response = jsonNewMessage(AFB_SUCCESS, "Ping Binder Daemon %d query={%s} PostData: \'%s\' ", pingcount++, query, request->post); - response = jsonNewMessage(AFB_SUCCESS, "Ping Application Framework %d [arg=%s]", pingcount++, argval); if (verbose) fprintf(stderr, "%d: \n", pingcount); return (response); -}; +} STATIC AFB_restapi pluginApis[]= { - {"/ping" , (AFB_apiCB)pingSample ,"Ping Service"}, - {"/get-all" , (AFB_apiCB)pingAfbs ,"Ping Application Framework"}, - {"/get-one" , (AFB_apiCB)pingSample ,"Verbose Mode"}, - {"/start-one", (AFB_apiCB)pingSample ,"Verbose Mode"}, - {"/stop-one" , (AFB_apiCB)pingSample ,"Verbose Mode"}, - {"/probe-one", (AFB_apiCB)pingSample ,"Verbose Mode"}, - {"/ctx-store", (AFB_apiCB)pingSample ,"Verbose Mode"}, - {"/ctx-load" , (AFB_apiCB)pingSample ,"Verbose Mode"}, + {"ping" , (AFB_apiCB)pingSample ,"Ping Service", NULL}, + {"get-all" , (AFB_apiCB)pingSample ,"Ping Application Framework", NULL}, + {"get-one" , (AFB_apiCB)pingSample ,"Verbose Mode", NULL}, + {"start-one", (AFB_apiCB)pingSample ,"Verbose Mode", NULL}, + {"stop-one" , (AFB_apiCB)pingSample ,"Verbose Mode", NULL}, + {"probe-one", (AFB_apiCB)pingSample ,"Verbose Mode", NULL}, + {"ctx-store", (AFB_apiCB)pingSample ,"Verbose Mode", NULL}, + {"ctx-load" , (AFB_apiCB)pingSample ,"Verbose Mode", NULL}, {0,0,0} }; PUBLIC AFB_plugin *afsvRegister (AFB_session *session) { - AFB_plugin plugin; - plugin.type = AFB_PLUGIN; - plugin.info = "Application Framework Binder Service"; - plugin.prefix= "afbs"; // url base - plugin.apis = pluginApis; + AFB_plugin *plugin = malloc (sizeof (AFB_plugin)); + plugin->type = AFB_PLUGIN; + plugin->info = "Application Framework Binder Service"; + plugin->prefix= "afbs"; // url base + plugin->apis = pluginApis; - return (&plugin); + return (plugin); }; \ No newline at end of file