MXS-1220: Use JSON output in dbfwfilter module commands

Added a new module command to the dbfwfilter to allow printing of rules
via the REST API. The old module command, `rules`, is now deprecated.
This commit is contained in:
Markus Mäkelä
2017-06-09 10:31:41 +03:00
parent b3c1e15f22
commit 06995837cf
2 changed files with 42 additions and 2 deletions

View File

@ -1717,11 +1717,18 @@ static void callModuleCommand(DCB *dcb, char *domain, char *id, char *v3,
if (arg)
{
// TODO: Print output instead of passing a writable DCB to the command
if (!modulecmd_call_command(cmd, arg, NULL))
json_t* output = NULL;
if (!modulecmd_call_command(cmd, arg, &output))
{
dcb_printf(dcb, "Error: %s\n", modulecmd_get_error());
}
else if (output)
{
dcb_printf(dcb, "%s\n", json_dumps(output, JSON_INDENT(4)));
}
json_decref(output);
modulecmd_arg_free(arg);
}
else