mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
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 ........ Merged revisions 402787 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402788 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -89,8 +89,6 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
|
|||||||
struct ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
void *obj;
|
void *obj;
|
||||||
|
|
||||||
/* TODO - if tech isn't a recognized type of endpoint, it should 404 */
|
|
||||||
|
|
||||||
cache = ast_endpoint_cache();
|
cache = ast_endpoint_cache();
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
ast_ari_response_error(
|
ast_ari_response_error(
|
||||||
@@ -131,7 +129,12 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
|
|||||||
}
|
}
|
||||||
ao2_iterator_destroy(&i);
|
ao2_iterator_destroy(&i);
|
||||||
|
|
||||||
|
if (ast_json_array_size(json)) {
|
||||||
ast_ari_response_ok(response, ast_json_ref(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,
|
void ast_ari_endpoints_get(struct ast_variable *headers,
|
||||||
struct ast_ari_endpoints_get_args *args,
|
struct ast_ari_endpoints_get_args *args,
|
||||||
|
@@ -134,6 +134,7 @@ static void ast_ari_endpoints_list_by_tech_cb(
|
|||||||
break;
|
break;
|
||||||
case 500: /* Internal Server Error */
|
case 500: /* Internal Server Error */
|
||||||
case 501: /* Not Implemented */
|
case 501: /* Not Implemented */
|
||||||
|
case 404: /* Endpoints not found */
|
||||||
is_valid = 1;
|
is_valid = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -193,6 +194,7 @@ static void ast_ari_endpoints_get_cb(
|
|||||||
break;
|
break;
|
||||||
case 500: /* Internal Server Error */
|
case 500: /* Internal Server Error */
|
||||||
case 501: /* Not Implemented */
|
case 501: /* Not Implemented */
|
||||||
|
case 404: /* Endpoints not found */
|
||||||
is_valid = 1;
|
is_valid = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@@ -35,6 +35,12 @@
|
|||||||
"paramType": "path",
|
"paramType": "path",
|
||||||
"dataType": "string"
|
"dataType": "string"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"errorResponses": [
|
||||||
|
{
|
||||||
|
"code": 404,
|
||||||
|
"reason": "Endpoints not found"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -61,6 +67,12 @@
|
|||||||
"paramType": "path",
|
"paramType": "path",
|
||||||
"dataType": "string"
|
"dataType": "string"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"errorResponses": [
|
||||||
|
{
|
||||||
|
"code": 404,
|
||||||
|
"reason": "Endpoints not found"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user