summaryrefslogtreecommitdiff
path: root/rest-api-templates/param_parsing.mustache
blob: d43dcdce2676104f62bd0640449d1070b7414ef5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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}}