[asterisk-commits] kharwell: branch 12 r402787 - in /branches/12: res/ res/ari/ rest-api/api-docs/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 12 16:15:43 CST 2013
Author: kharwell
Date: Tue Nov 12 16:15:41 2013
New Revision: 402787
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402787
Log:
ari endpoints: GET /ari/endpoints/{invalid-tech} should return a 404
Implementation listing endpoints by technology returned an empty array if no
matching endpoints were found. Fixed so a "404 Not Found" will be returned
instead.
(closes issue ASTERISK-22803)
Reported by: David M. Lee
Modified:
branches/12/res/ari/resource_endpoints.c
branches/12/res/res_ari_endpoints.c
branches/12/rest-api/api-docs/endpoints.json
Modified: branches/12/res/ari/resource_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/ari/resource_endpoints.c?view=diff&rev=402787&r1=402786&r2=402787
==============================================================================
--- branches/12/res/ari/resource_endpoints.c (original)
+++ branches/12/res/ari/resource_endpoints.c Tue Nov 12 16:15:41 2013
@@ -89,8 +89,6 @@
struct ao2_iterator i;
void *obj;
- /* TODO - if tech isn't a recognized type of endpoint, it should 404 */
-
cache = ast_endpoint_cache();
if (!cache) {
ast_ari_response_error(
@@ -131,7 +129,12 @@
}
ao2_iterator_destroy(&i);
- ast_ari_response_ok(response, ast_json_ref(json));
+ if (ast_json_array_size(json)) {
+ ast_ari_response_ok(response, ast_json_ref(json));
+ } else {
+ ast_ari_response_error(response, 404, "Not Found",
+ "No Endpoints found with tech %s", args->tech);
+ }
}
void ast_ari_endpoints_get(struct ast_variable *headers,
struct ast_ari_endpoints_get_args *args,
Modified: branches/12/res/res_ari_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_ari_endpoints.c?view=diff&rev=402787&r1=402786&r2=402787
==============================================================================
--- branches/12/res/res_ari_endpoints.c (original)
+++ branches/12/res/res_ari_endpoints.c Tue Nov 12 16:15:41 2013
@@ -134,6 +134,7 @@
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
+ case 404: /* Endpoints not found */
is_valid = 1;
break;
default:
@@ -193,6 +194,7 @@
break;
case 500: /* Internal Server Error */
case 501: /* Not Implemented */
+ case 404: /* Endpoints not found */
is_valid = 1;
break;
default:
Modified: branches/12/rest-api/api-docs/endpoints.json
URL: http://svnview.digium.com/svn/asterisk/branches/12/rest-api/api-docs/endpoints.json?view=diff&rev=402787&r1=402786&r2=402787
==============================================================================
--- branches/12/rest-api/api-docs/endpoints.json (original)
+++ branches/12/rest-api/api-docs/endpoints.json Tue Nov 12 16:15:41 2013
@@ -35,6 +35,12 @@
"paramType": "path",
"dataType": "string"
}
+ ],
+ "errorResponses": [
+ {
+ "code": 404,
+ "reason": "Endpoints not found"
+ }
]
}
]
@@ -60,6 +66,12 @@
"description": "ID of the endpoint",
"paramType": "path",
"dataType": "string"
+ }
+ ],
+ "errorResponses": [
+ {
+ "code": 404,
+ "reason": "Endpoints not found"
}
]
}
More information about the asterisk-commits
mailing list