summaryrefslogtreecommitdiffstats
path: root/ctl-lib
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-11-22 10:52:30 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 15:02:55 +0100
commit26d581e7727ef952d1f849800b33961a36393b5c (patch)
tree48832a59baaea84522990ce59556f4906e0ca726 /ctl-lib
parent08fa7e02f1fb376210a0fc52cca9dbff370c72d5 (diff)
AFB:servsync: add string for query argument
for query argument add string that will be converted to json object Change-Id: I75b669a6c02838fd31017b82e9093966f3eea0e6 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'ctl-lib')
-rw-r--r--ctl-lib/ctl-lua.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ctl-lib/ctl-lua.c b/ctl-lib/ctl-lua.c
index 1a2554c..08c9b85 100644
--- a/ctl-lib/ctl-lua.c
+++ b/ctl-lib/ctl-lua.c
@@ -498,7 +498,7 @@ static int LuaAfbServiceSync(lua_State* luaState) {
}
// note: argument start at 2 because of AFB: table
- if (count != 5 || !lua_isstring(luaState, LUA_FIRST_ARG + 1) || !lua_isstring(luaState, LUA_FIRST_ARG + 2) || !lua_istable(luaState, LUA_FIRST_ARG + 3)) {
+ if (count != 5 || !lua_isstring(luaState, LUA_FIRST_ARG + 1) || !lua_isstring(luaState, LUA_FIRST_ARG + 2) || (!lua_istable(luaState, LUA_FIRST_ARG + 3) && !lua_isstring(luaState, LUA_FIRST_ARG +3))) {
lua_pushliteral(luaState, "ERROR: syntax AFB:servsync(source, api, verb, {[Lua Table]})");
lua_error(luaState);
return 1;
@@ -508,7 +508,12 @@ static int LuaAfbServiceSync(lua_State* luaState) {
// get source/api/verb+query
const char *api = lua_tostring(luaState, LUA_FIRST_ARG + 1);
const char *verb = lua_tostring(luaState, LUA_FIRST_ARG + 2);
- json_object *queryJ = LuaTableToJson(source, luaState, LUA_FIRST_ARG + 3);
+ json_object *queryJ = NULL;
+ if (lua_istable(luaState, LUA_FIRST_ARG + 3)) {
+ queryJ = LuaTableToJson(source, luaState, LUA_FIRST_ARG + 3);
+ } else {
+ queryJ = json_object_new_string(lua_tostring(luaState, LUA_FIRST_ARG + 3));
+ }
int iserror = AFB_ServiceSync(source->api, api, verb, queryJ, &responseJ);