]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Add stats exporter service infrastructure.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 14 Nov 2019 23:34:32 +0000 (00:34 +0100)
committermartti.rannanjarvi <martti.rannanjarvi@open-xchange.com>
Sat, 18 Apr 2020 14:55:11 +0000 (14:55 +0000)
src/stats/Makefile.am
src/stats/client-http.c
src/stats/main.c
src/stats/stats-service-private.h [new file with mode: 0644]
src/stats/stats-service.c [new file with mode: 0644]
src/stats/stats-service.h [new file with mode: 0644]

index 10aa86c594463d582849a8b1bab1907dfeaac7ef..d1d4ad6a26f4399cb83eca3d1594f503304d01c0 100644 (file)
@@ -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 \
index 6ffcb933b8c870388e464ebcd015ffc45ecf2cf3..f6b6b77598987acacb4275a2b1a510c8628dc0a3 100644 (file)
@@ -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') {
index f9204568fa3e7f2862b928a4d60aedfe86ea0673..1c74f0106a350a0616ffda5ae20dd97860b347fa 100644 (file)
@@ -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 (file)
index 0000000..f684210
--- /dev/null
@@ -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 (file)
index 0000000..a26d697
--- /dev/null
@@ -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 (file)
index 0000000..fab477b
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef STATS_SERVICE_H
+#define STATS_SERVICE_H
+
+void stats_services_init(void);
+void stats_services_deinit(void);
+
+#endif