|
34 | 34 |
|
35 | 35 | #define HTTP_CONTENT_JSON 0
|
36 | 36 | #define HTTP_CONTENT_URLENCODED 1
|
| 37 | +#define HTTP_HEALTH_ENDPOINT "/health" |
37 | 38 |
|
38 | 39 | static inline char hex2nibble(char c)
|
39 | 40 | {
|
@@ -95,18 +96,19 @@ cfl_sds_t get_health_message()
|
95 | 96 | tm_time.tm_year + 1900, tm_time.tm_mon + 1, tm_time.tm_mday,
|
96 | 97 | tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec, tm.tm.tv_nsec);
|
97 | 98 |
|
98 |
| - msg = cfl_sds_create_size(256); |
| 99 | + msg = cfl_sds_create_size(512); |
99 | 100 | if (!msg) {
|
100 | 101 | return NULL;
|
101 | 102 | }
|
102 | 103 |
|
103 | 104 | cfl_sds_printf(&msg,
|
104 | 105 | "{\n"
|
105 | 106 | " \"status\": \"ok\",\n"
|
106 |
| - " \"message\": \"I can only show you the door. You're the one that has to walk through it.\",\n" |
| 107 | + " \"version\": \"%s\",\n" |
| 108 | + " \"git_hash\": \"%s\",\n" |
107 | 109 | " \"timestamp\": \"%s\"\n"
|
108 | 110 | "}\n",
|
109 |
| - time_str); |
| 111 | + FLB_VERSION_STR, FLB_GIT_HASH, time_str); |
110 | 112 |
|
111 | 113 | return msg;
|
112 | 114 | }
|
@@ -990,7 +992,7 @@ int http_prot_handle(struct flb_http *ctx, struct http_conn *conn,
|
990 | 992 | request->_content_length.data = NULL;
|
991 | 993 | }
|
992 | 994 |
|
993 |
| - if (request->method == MK_METHOD_GET && strcmp(uri, "/health") == 0) { |
| 995 | + if (request->method == MK_METHOD_GET && strcmp(uri, HTTP_HEALTH_ENDPOINT) == 0 && ctx->enable_health_endpoint) { |
994 | 996 | flb_sds_destroy(tag);
|
995 | 997 | mk_mem_free(uri);
|
996 | 998 | health = get_health_message();
|
@@ -1324,7 +1326,7 @@ int http_prot_handle_ng(struct flb_http_request *request,
|
1324 | 1326 | return -1;
|
1325 | 1327 | }
|
1326 | 1328 |
|
1327 |
| - if (request->method == HTTP_METHOD_GET && strcmp(request->path, "/health") == 0) { |
| 1329 | + if (request->method == HTTP_METHOD_GET && strcmp(request->path, HTTP_HEALTH_ENDPOINT) == 0 && ctx->enable_health_endpoint) { |
1328 | 1330 | flb_sds_destroy(tag);
|
1329 | 1331 | health = get_health_message();
|
1330 | 1332 | send_response_ng(response, 200, health);
|
|
0 commit comments