summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-11-27 15:48:39 +0000
committerDavid M. Lee <dlee@digium.com>2013-11-27 15:48:39 +0000
commitfccb427c88e6b6e0ae8627ffcdc06f4ae5077d34 (patch)
treef3aa4bd4148bd818be174ee8648c3d50300ceec7 /include/asterisk
parentfd33969240111a9ad2fdd305461265b315ce13dd (diff)
ari:Add application/json parameter support
The patch allows ARI to parse request parameters from an incoming JSON request body, instead of requiring the request to come in as query parameters (which is just weird for POST and DELETE) or form parameters (which is okay, but a bit asymmetric given that all of our responses are JSON). For any operation that does _not_ have a parameter defined of type body (i.e. "paramType": "body" in the API declaration), if a request provides a request body with a Content type of "application/json", the provided JSON document is parsed and searched for parameters. The expected fields in the provided JSON document should match the query parameters defined for the operation. If the parameter has 'allowMultiple' set, then the field in the JSON document may optionally be an array of values. (closes issue ASTERISK-22685) Review: https://reviewboard.asterisk.org/r/2994/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403177 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/ari.h9
-rw-r--r--include/asterisk/http.h12
2 files changed, 17 insertions, 4 deletions
diff --git a/include/asterisk/ari.h b/include/asterisk/ari.h
index dfeef513c..f5b76f8dc 100644
--- a/include/asterisk/ari.h
+++ b/include/asterisk/ari.h
@@ -50,15 +50,16 @@ struct ast_ari_response;
/*!
* \brief Callback type for RESTful method handlers.
+ * \param ser TCP/TLS session object
* \param get_params GET parameters from the HTTP request.
* \param path_vars Path variables from any wildcard path segments.
* \param headers HTTP headers from the HTTP requiest.
* \param[out] response The RESTful response.
*/
-typedef void (*stasis_rest_callback)(struct ast_variable *get_params,
- struct ast_variable *path_vars,
- struct ast_variable *headers,
- struct ast_ari_response *response);
+typedef void (*stasis_rest_callback)(
+ struct ast_tcptls_session_instance *ser,
+ struct ast_variable *get_params, struct ast_variable *path_vars,
+ struct ast_variable *headers, struct ast_ari_response *response);
/*!
* \brief Handler for a single RESTful path segment.
diff --git a/include/asterisk/http.h b/include/asterisk/http.h
index 59e185a6f..0642cfa9b 100644
--- a/include/asterisk/http.h
+++ b/include/asterisk/http.h
@@ -212,5 +212,17 @@ void ast_http_prefix(char *buf, int len);
*/
struct ast_variable *ast_http_get_post_vars(struct ast_tcptls_session_instance *ser, struct ast_variable *headers);
+struct ast_json;
+
+/*!\brief Get JSON from client Request Entity-Body, if content type is
+ * application/json.
+ * \param ser TCP/TLS session object
+ * \param headers List of HTTP headers
+ * \return Parsed JSON content body
+ * \return \c NULL on error, if no content, or if different content type.
+ * \since 12
+ */
+struct ast_json *ast_http_get_json(
+ struct ast_tcptls_session_instance *ser, struct ast_variable *headers);
#endif /* _ASTERISK_SRV_H */