summaryrefslogtreecommitdiffstats
path: root/web/api/health
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2019-09-03 11:23:32 +0000
committerGitHub <noreply@github.com>2019-09-03 11:23:32 +0000
commit982890f8eab8ccf53d030478d7ea5ad6e3207b40 (patch)
treeb3b761ffeb37ad95a709dbd655a15d7b59013e41 /web/api/health
parentc274f5d1b3544f269e3c5529bf30b4c531963a4a (diff)
HTTP response message (#6595)
* health_connection: http_error_pattern This commit brings an unique pattern for the Netdata webserver errors, now Netdata uses define for all web error * http_error_pattern: API v1 This PR also brings the pattern for the web_api_v1.c
Diffstat (limited to 'web/api/health')
-rw-r--r--web/api/health/health_cmdapi.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/web/api/health/health_cmdapi.c b/web/api/health/health_cmdapi.c
index 94293dbe68..4dd85e6b16 100644
--- a/web/api/health/health_cmdapi.c
+++ b/web/api/health/health_cmdapi.c
@@ -116,7 +116,7 @@ void health_silencers2file(BUFFER *wb) {
* @return It returns 200 on success and another code otherwise.
*/
int web_client_api_request_v1_mgmt_health(RRDHOST *host, struct web_client *w, char *url) {
- int ret = 400;
+ int ret;
(void) host;
BUFFER *wb = w->response.data;
@@ -131,12 +131,12 @@ int web_client_api_request_v1_mgmt_health(RRDHOST *host, struct web_client *w, c
if (!w->auth_bearer_token) {
buffer_strcat(wb, HEALTH_CMDAPI_MSG_AUTHERROR);
- ret = 403;
+ ret = HTTP_RESP_FORBIDDEN;
} else {
debug(D_HEALTH, "HEALTH command API: Comparing secret '%s' to '%s'", w->auth_bearer_token, api_secret);
if (strcmp(w->auth_bearer_token, api_secret)) {
buffer_strcat(wb, HEALTH_CMDAPI_MSG_AUTHERROR);
- ret = 403;
+ ret = HTTP_RESP_FORBIDDEN;
} else {
while (url) {
char *value = mystrsep(&url, "&");
@@ -190,12 +190,12 @@ int web_client_api_request_v1_mgmt_health(RRDHOST *host, struct web_client *w, c
if (unlikely(silencers->stype != STYPE_NONE && !silencers->all_alarms && !silencers->silencers)) {
buffer_strcat(wb, HEALTH_CMDAPI_MSG_NOSELECTORWARNING);
}
- ret = 200;
+ ret = HTTP_RESP_OK;
}
}
w->response.data = wb;
buffer_no_cacheable(w->response.data);
- if (ret == 200 && config_changed) {
+ if (ret == HTTP_RESP_OK && config_changed) {
BUFFER *jsonb = buffer_create(200);
health_silencers2json(jsonb);
health_silencers2file(jsonb);