From: Stephan Bosch Date: Thu, 14 Nov 2019 23:34:32 +0000 (+0100) Subject: stats: Add stats exporter service infrastructure. X-Git-Tag: 2.3.11.2~313 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=390832afd5ee5e46c69126968aff32409d221e9f;p=thirdparty%2Fdovecot%2Fcore.git stats: Add stats exporter service infrastructure. --- diff --git a/src/stats/Makefile.am b/src/stats/Makefile.am index 10aa86c594..d1d4ad6a26 100644 --- a/src/stats/Makefile.am +++ b/src/stats/Makefile.am @@ -25,6 +25,8 @@ stats_DEPENDENCIES = \ $(DOVECOT_SSL_LIBS) \ $(LIBDOVECOT_DEPS) +stats_services = + stats_SOURCES = \ main.c @@ -39,6 +41,8 @@ libstats_local_la_SOURCES = \ event-exporter-transport-drop.c \ event-exporter-transport-http-post.c \ event-exporter-transport-log.c \ + $(stats_services) \ + stats-service.c \ stats-event-category.c \ stats-metrics.c \ stats-settings.c @@ -49,6 +53,8 @@ noinst_HEADERS = \ client-writer.h \ client-http.h\ event-exporter.h \ + stats-service.h \ + stats-service-private.h \ stats-event-category.h \ stats-metrics.h \ stats-settings.h \ diff --git a/src/stats/client-http.c b/src/stats/client-http.c index 6ffcb933b8..f6b6b77598 100644 --- a/src/stats/client-http.c +++ b/src/stats/client-http.c @@ -10,6 +10,7 @@ #include "http-server.h" #include "http-url.h" #include "stats-metrics.h" +#include "stats-service.h" #include "client-http.h" struct stats_http_client; @@ -188,11 +189,12 @@ stats_http_resource_root_request(void *context ATTR_UNUSED, if (strcmp(hreq->method, "OPTIONS") == 0) { resp = http_server_response_create(req, 200, "OK"); + http_server_response_add_header(resp, "Allow", "GET"); http_server_response_submit(resp); return; } if (strcmp(hreq->method, "GET") != 0) { - http_server_request_fail(req, 405, "Method Not Allowed"); + http_server_request_fail_bad_method(req, "GET"); return; } if (*sub_path != '\0') { diff --git a/src/stats/main.c b/src/stats/main.c index f9204568fa..1c74f0106a 100644 --- a/src/stats/main.c +++ b/src/stats/main.c @@ -8,6 +8,7 @@ #include "stats-settings.h" #include "stats-event-category.h" #include "stats-metrics.h" +#include "stats-service.h" #include "client-writer.h" #include "client-reader.h" #include "client-http.h" @@ -68,10 +69,12 @@ static void main_init(void) client_readers_init(); client_writers_init(); client_http_init(); + stats_services_init(); } static void main_deinit(void) { + stats_services_deinit(); client_readers_deinit(); client_writers_deinit(); client_http_deinit(); diff --git a/src/stats/stats-service-private.h b/src/stats/stats-service-private.h new file mode 100644 index 0000000000..f6842106c8 --- /dev/null +++ b/src/stats/stats-service-private.h @@ -0,0 +1,6 @@ +#ifndef STATS_SERVICE_PRIVATE_H +#define STATS_SERVICE_PRIVATE_H + +#include "stats-service.h" + +#endif diff --git a/src/stats/stats-service.c b/src/stats/stats-service.c new file mode 100644 index 0000000000..a26d697e9d --- /dev/null +++ b/src/stats/stats-service.c @@ -0,0 +1,15 @@ +/* Copyright (c) 2019 Dovecot authors, see the included COPYING file */ + +#include "stats-common.h" +#include "http-server.h" +#include "stats-service-private.h" + +void stats_services_init(void) +{ + /* Nothing yet */ +} + +void stats_services_deinit(void) +{ + /* Nothing yet */ +} diff --git a/src/stats/stats-service.h b/src/stats/stats-service.h new file mode 100644 index 0000000000..fab477b565 --- /dev/null +++ b/src/stats/stats-service.h @@ -0,0 +1,7 @@ +#ifndef STATS_SERVICE_H +#define STATS_SERVICE_H + +void stats_services_init(void); +void stats_services_deinit(void); + +#endif