Skip to content
This repository was archived by the owner on Jun 17, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions promhttp/include/promhttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@ void promhttp_set_active_collector_registry(prom_collector_registry_t *active_re
*/
struct MHD_Daemon *promhttp_start_daemon(unsigned int flags, unsigned short port, MHD_AcceptPolicyCallback apc,
void *apc_cls);

/**
* @brief Starts a daemon in the background and returns a pointer to an MHD_Daemon.
*
* This is the same as promhttp_start_daemon(), except it allows applications
* to pass options to MHD_start_daemon() directly.
*
* @return struct MHD_Daemon*
*/
struct MHD_Daemon *promhttp_start_daemon_with_options(unsigned int flags, unsigned short port,
MHD_AcceptPolicyCallback apc,
void *apc_cls, ...);

20 changes: 20 additions & 0 deletions promhttp/src/promhttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include <string.h>
#include <stdarg.h>

#include "microhttpd.h"
#include "prom.h"
Expand Down Expand Up @@ -63,3 +64,22 @@ struct MHD_Daemon *promhttp_start_daemon(unsigned int flags, unsigned short port
void *apc_cls) {
return MHD_start_daemon(flags, port, apc, apc_cls, &promhttp_handler, NULL, MHD_OPTION_END);
}

static struct MHD_Daemon *promhttp_start_daemon_with_options_va(unsigned int flags, unsigned short port,
MHD_AcceptPolicyCallback apc,
void *apc_cls, va_list ap) {
return MHD_start_daemon_va(flags, port, apc, apc_cls, &promhttp_handler, NULL, ap);
}

struct MHD_Daemon *promhttp_start_daemon_with_options(unsigned int flags, unsigned short port,
MHD_AcceptPolicyCallback apc,
void *apc_cls, ...) {
va_list ap;
struct MHD_Daemon *ret;

va_start(ap, apc_cls);
ret = promhttp_start_daemon_with_options_va(flags, port, apc, apc_cls, ap);
va_end(ap);

return ret;
}