|
|
|
@ -818,9 +818,14 @@ static void stasis_http_record_channel_cb(
|
|
|
|
|
* \param[out] response Response to the HTTP request.
|
|
|
|
|
*/
|
|
|
|
|
static void stasis_http_get_channel_var_cb(
|
|
|
|
|
struct ast_variable *get_params, struct ast_variable *path_vars,
|
|
|
|
|
struct ast_variable *headers, struct stasis_http_response *response)
|
|
|
|
|
struct ast_variable *get_params, struct ast_variable *path_vars,
|
|
|
|
|
struct ast_variable *headers, struct stasis_http_response *response)
|
|
|
|
|
{
|
|
|
|
|
#if defined(AST_DEVMODE)
|
|
|
|
|
int is_valid;
|
|
|
|
|
int code;
|
|
|
|
|
#endif /* AST_DEVMODE */
|
|
|
|
|
|
|
|
|
|
struct ast_get_channel_var_args args = {};
|
|
|
|
|
struct ast_variable *i;
|
|
|
|
|
|
|
|
|
@ -837,6 +842,31 @@ static void stasis_http_get_channel_var_cb(
|
|
|
|
|
{}
|
|
|
|
|
}
|
|
|
|
|
stasis_http_get_channel_var(headers, &args, response);
|
|
|
|
|
#if defined(AST_DEVMODE)
|
|
|
|
|
code = response->response_code;
|
|
|
|
|
|
|
|
|
|
switch (code) {
|
|
|
|
|
case 500: /* Internal server error */
|
|
|
|
|
case 404: /* Channel not found */
|
|
|
|
|
case 409: /* Channel not in a Stasis application */
|
|
|
|
|
is_valid = 1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (200 <= code && code <= 299) {
|
|
|
|
|
is_valid = ari_validate_variable(
|
|
|
|
|
response->message);
|
|
|
|
|
} else {
|
|
|
|
|
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/variable\n", code);
|
|
|
|
|
is_valid = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!is_valid) {
|
|
|
|
|
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/variable\n");
|
|
|
|
|
stasis_http_response_error(response, 500,
|
|
|
|
|
"Internal Server Error", "Response validation failed");
|
|
|
|
|
}
|
|
|
|
|
#endif /* AST_DEVMODE */
|
|
|
|
|
}
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Parameter parsing callback for /channels/{channelId}/variable.
|
|
|
|
@ -846,9 +876,14 @@ static void stasis_http_get_channel_var_cb(
|
|
|
|
|
* \param[out] response Response to the HTTP request.
|
|
|
|
|
*/
|
|
|
|
|
static void stasis_http_set_channel_var_cb(
|
|
|
|
|
struct ast_variable *get_params, struct ast_variable *path_vars,
|
|
|
|
|
struct ast_variable *headers, struct stasis_http_response *response)
|
|
|
|
|
struct ast_variable *get_params, struct ast_variable *path_vars,
|
|
|
|
|
struct ast_variable *headers, struct stasis_http_response *response)
|
|
|
|
|
{
|
|
|
|
|
#if defined(AST_DEVMODE)
|
|
|
|
|
int is_valid;
|
|
|
|
|
int code;
|
|
|
|
|
#endif /* AST_DEVMODE */
|
|
|
|
|
|
|
|
|
|
struct ast_set_channel_var_args args = {};
|
|
|
|
|
struct ast_variable *i;
|
|
|
|
|
|
|
|
|
@ -868,6 +903,31 @@ static void stasis_http_set_channel_var_cb(
|
|
|
|
|
{}
|
|
|
|
|
}
|
|
|
|
|
stasis_http_set_channel_var(headers, &args, response);
|
|
|
|
|
#if defined(AST_DEVMODE)
|
|
|
|
|
code = response->response_code;
|
|
|
|
|
|
|
|
|
|
switch (code) {
|
|
|
|
|
case 500: /* Internal server error */
|
|
|
|
|
case 404: /* Channel not found */
|
|
|
|
|
case 409: /* Channel not in a Stasis application */
|
|
|
|
|
is_valid = 1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (200 <= code && code <= 299) {
|
|
|
|
|
is_valid = ari_validate_void(
|
|
|
|
|
response->message);
|
|
|
|
|
} else {
|
|
|
|
|
ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/variable\n", code);
|
|
|
|
|
is_valid = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!is_valid) {
|
|
|
|
|
ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/variable\n");
|
|
|
|
|
stasis_http_response_error(response, 500,
|
|
|
|
|
"Internal Server Error", "Response validation failed");
|
|
|
|
|
}
|
|
|
|
|
#endif /* AST_DEVMODE */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief REST handler for /api-docs/channels.{format} */
|
|
|
|
|