summaryrefslogtreecommitdiff
path: root/rest-api-templates/param_parsing.mustache
diff options
context:
space:
mode:
Diffstat (limited to 'rest-api-templates/param_parsing.mustache')
-rw-r--r--rest-api-templates/param_parsing.mustache45
1 files changed, 45 insertions, 0 deletions
diff --git a/rest-api-templates/param_parsing.mustache b/rest-api-templates/param_parsing.mustache
new file mode 100644
index 000000000..d43dcdce2
--- /dev/null
+++ b/rest-api-templates/param_parsing.mustache
@@ -0,0 +1,45 @@
+{{!
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013, Digium, Inc.
+ *
+ * David M. Lee, II <dlee@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+}}
+{{!
+ * Snippet for decoding parameters into an _args struct.
+}}
+ struct ast_{{c_nickname}}_args args = {};
+{{#has_parameters}}
+ struct ast_variable *i;
+
+{{#has_query_parameters}}
+ for (i = get_params; i; i = i->next) {
+{{#query_parameters}}
+ if (strcmp(i->name, "{{name}}") == 0) {
+ args.{{c_name}} = {{c_convert}}(i->value);
+ } else
+{{/query_parameters}}
+ {}
+ }
+{{/has_query_parameters}}
+{{#has_path_parameters}}
+ for (i = path_vars; i; i = i->next) {
+{{#path_parameters}}
+ if (strcmp(i->name, "{{name}}") == 0) {
+ args.{{c_name}} = {{c_convert}}(i->value);
+ } else
+{{/path_parameters}}
+ {}
+ }
+{{/has_path_parameters}}
+{{/has_parameters}}