diff options
author | Kinsey Moore <kmoore@digium.com> | 2014-01-21 14:27:21 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2014-01-21 14:27:21 +0000 |
commit | 1590d32ab0a5b6797c96244a47f18f868574e970 (patch) | |
tree | 3cc0717778b4d2b816ba4df12bb76a75716631b3 /res/res_ari_device_states.c | |
parent | 4bc84b1b9f25b6bdfab7daef9c08000fb31d5a43 (diff) |
ARI: Support channel variables in originate
This adds back in support for specifying channel variables during an
originate without compromising the ability to specify query parameters
in the JSON body. This was accomplished by generating the body-parsing
code in a separate function instead of being integrated with the URI
query parameter parsing code such that it could be called by paths with
body parameters. This is transparent to the user of the API and
prevents manual duplication of code or data structures.
(closes issue ASTERISK-23051)
Review: https://reviewboard.asterisk.org/r/3122/
Reported by: Matt Jordan
........
Merged revisions 406003 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@406006 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_ari_device_states.c')
-rw-r--r-- | res/res_ari_device_states.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/res/res_ari_device_states.c b/res/res_ari_device_states.c index a8079f139..5576a1859 100644 --- a/res/res_ari_device_states.c +++ b/res/res_ari_device_states.c @@ -160,6 +160,19 @@ static void ast_ari_device_states_get_cb( fin: __attribute__((unused)) return; } +int ast_ari_device_states_update_parse_body( + struct ast_json *body, + struct ast_ari_device_states_update_args *args) +{ + struct ast_json *field; + /* Parse query parameters out of it */ + field = ast_json_object_get(body, "deviceState"); + if (field) { + args->device_state = ast_json_string_get(field); + } + return 0; +} + /*! * \brief Parameter parsing callback for /deviceStates/{deviceName}. * \param get_params GET parameters in the HTTP request. @@ -175,7 +188,6 @@ static void ast_ari_device_states_update_cb( struct ast_ari_device_states_update_args args = {}; struct ast_variable *i; RAII_VAR(struct ast_json *, body, NULL, ast_json_unref); - struct ast_json *field; #if defined(AST_DEVMODE) int is_valid; int code; @@ -208,10 +220,9 @@ static void ast_ari_device_states_update_cb( goto fin; } } - /* Parse query parameters out of it */ - field = ast_json_object_get(body, "deviceState"); - if (field) { - args.device_state = ast_json_string_get(field); + if (ast_ari_device_states_update_parse_body(body, &args)) { + ast_ari_response_alloc_failed(response); + goto fin; } ast_ari_device_states_update(headers, &args, response); #if defined(AST_DEVMODE) |