mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-20 12:20:12 +00:00
This patch adds a RESTful HTTP interface to Asterisk.
The API itself is documented using Swagger, a lightweight mechanism for documenting RESTful API's using JSON. This allows us to use swagger-ui to provide executable documentation for the API, generate client bindings in different languages, and generate a lot of the boilerplate code for implementing the RESTful bindings. The API docs live in the rest-api/ directory. The RESTful bindings are generated from the Swagger API docs using a set of Mustache templates. The code generator is written in Python, and uses Pystache. Pystache has no dependencies, and be installed easily using pip. Code generation code lives in rest-api-templates/. The generated code reduces a lot of boilerplate when it comes to handling HTTP requests. It also helps us have greater consistency in the REST API. (closes issue ASTERISK-20891) Review: https://reviewboard.asterisk.org/r/2376/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386232 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -82,6 +82,48 @@ static force_inline int attribute_pure ast_strlen_zero(const char *s)
|
||||
*/
|
||||
#define S_COR(a, b, c) ({typeof(&((b)[0])) __x = (b); (a) && !ast_strlen_zero(__x) ? (__x) : (c);})
|
||||
|
||||
/*
|
||||
\brief Checks whether a string begins with another.
|
||||
\since 12.0.0
|
||||
\param str String to check.
|
||||
\param prefix Prefix to look for.
|
||||
\param 1 if \a str begins with \a prefix, 0 otherwise.
|
||||
*/
|
||||
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
|
||||
{
|
||||
ast_assert(str != NULL);
|
||||
ast_assert(prefix != NULL);
|
||||
while (*str == *prefix && *prefix != '\0') {
|
||||
++str;
|
||||
++prefix;
|
||||
}
|
||||
return *prefix == '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
\brief Checks whether a string ends with another.
|
||||
\since 12.0.0
|
||||
\param str String to check.
|
||||
\param suffix Suffix to look for.
|
||||
\param 1 if \a str ends with \a suffix, 0 otherwise.
|
||||
*/
|
||||
static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)
|
||||
{
|
||||
size_t str_len;
|
||||
size_t suffix_len;
|
||||
|
||||
ast_assert(str != NULL);
|
||||
ast_assert(suffix != NULL);
|
||||
str_len = strlen(str);
|
||||
suffix_len = strlen(suffix);
|
||||
|
||||
if (suffix_len > str_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return strcmp(str + str_len - suffix_len, suffix) == 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief return Yes or No depending on the argument.
|
||||
*
|
||||
|
Reference in New Issue
Block a user