<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/2376/">https://reviewboard.asterisk.org/r/2376/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On April 18th, 2013, 2 p.m. CDT, <b>opticron</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/2376/diff/5/?file=35884#file35884line92" style="color: black; font-weight: bold; text-decoration: underline;">/trunk/include/asterisk/strings.h</a>
<span style="font-weight: normal;">
(Diff revision 5)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static force_inline int attribute_pure ast_strlen_zero(const char *s)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">92</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="k">static</span> <span class="kt">int</span> <span class="n">force_inline</span> <span class="n">attribute_pure</span> <span class="nf">ast_begins_with</span><span class="p">(</span><span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">str</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">prefix</span><span class="p">)</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This will encounter problems when prefix is longer than str.</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Nope. The terminating '\0' in str won't match the corresponding character in prefix, which will cause the loop to exit. Since *prefix != '\0', the function will return false.</pre>
<br />
<p>- David</p>
<br />
<p>On April 12th, 2013, 1:39 p.m. CDT, David Lee wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By David Lee.</div>
<p style="color: grey;"><i>Updated April 12, 2013, 1:39 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This patch represents the first step toward adding a RESTful API to Asterisk.
The following is the file doc from res_stasis_http.c:
The API itself is documented using Swagger[1], a lightweight mechanism for
documenting RESTful API's using JSON. This allows us to use swagger-ui[2] to
provide executable documentation for the API, generate client bindings in
different languages[3], 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[4] templates. The code generator is written in
Python, and uses Pystache[5]. 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.
The structure of the generated code is:
- res/stasis_http/resource_{resource}.h
- For each operation in the resouce, a generated argument structure
(holding the parsed arguments from the request) and function
declarations (to implement in res/stasis_http/resource_{resource}.c)
- res_stasis_http_{resource}.c
- A set of \ref stasis_rest_callback functions, which glue the two
together. They parse out path variables and request parameters to
populate a specific \c_args which is passed to the specific request
handler (in res/stasis_http/resource_{resource}.c)
- A tree of \ref stasis_rest_handlers for routing requests to its
\ref stasis_rest_callback
The basic flow of an HTTP request is:
- stasis_http_callback()
1. Initial request validation
2. Routes as either a doc request (stasis_http_get_docs) or API
request (stasis_http_invoke)
- stasis_http_invoke()
1. Further request validation
2. Routes the request through the tree of generated
stasis_rest_handlers.
3. Dispatch to the generated callback
- stasis_http_*_cb
1. Populate *_args struct with path and get params
2. Invoke the request handler
3. Validates and sends response
[1]: https://developers.helloreverb.com/swagger/
[2]: https://github.com/wordnik/swagger-ui
[3]: https://github.com/asterisk/asterisk_rest_libraries
[4]: http://mustache.github.io/mustache.5.html
[5]: https://github.com/defunkt/pystache</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Unit tests</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/trunk/Makefile <span style="color: grey">(385119)</span></li>
<li>/trunk/apps/app_stasis.c <span style="color: grey">(385119)</span></li>
<li>/trunk/configs/stasis_http.conf.sample <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/include/asterisk/app_stasis.h <span style="color: grey">(385119)</span></li>
<li>/trunk/include/asterisk/http.h <span style="color: grey">(385119)</span></li>
<li>/trunk/include/asterisk/json.h <span style="color: grey">(385119)</span></li>
<li>/trunk/include/asterisk/stasis_http.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/include/asterisk/strings.h <span style="color: grey">(385119)</span></li>
<li>/trunk/include/asterisk/utils.h <span style="color: grey">(385119)</span></li>
<li>/trunk/main/http.c <span style="color: grey">(385119)</span></li>
<li>/trunk/main/json.c <span style="color: grey">(385119)</span></li>
<li>/trunk/res/Makefile <span style="color: grey">(385119)</span></li>
<li>/trunk/res/res_stasis_http.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/res_stasis_http.exports.in <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/res_stasis_http_asterisk.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/res_stasis_http_bridges.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/res_stasis_http_channels.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/res_stasis_http_endpoints.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/res_stasis_http_events.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/res_stasis_http_recordings.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http.make <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_asterisk.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_asterisk.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_bridges.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_bridges.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_channels.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_channels.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_endpoints.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_endpoints.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_events.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_events.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_recordings.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/res/stasis_http/resource_recordings.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/README.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/asterisk_processor.py <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/do-not-edit.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/make_stasis_http_stubs.py <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/odict.py <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/res_stasis_http_resource.c.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/rest_handler.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/stasis_http.make.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/stasis_http_resource.c.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/stasis_http_resource.h.mustache <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/swagger_model.py <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api-templates/transform.py <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api/README.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api/api-docs/asterisk.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api/api-docs/bridges.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api/api-docs/channels.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api/api-docs/endpoints.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api/api-docs/events.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api/api-docs/recordings.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/rest-api/resources.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/tests/test_stasis.c <span style="color: grey">(385119)</span></li>
<li>/trunk/tests/test_stasis_http.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>/trunk/tests/test_strings.c <span style="color: grey">(385119)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2376/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>