view mod_http_health/mod_http_health.lua @ 5688:429be658c0bb

mod_dnsupdate: Support advertising explicit non-existence of service
author Kim Alvefur <zash@zash.se>
date Fri, 03 Nov 2023 23:26:57 +0100
parents 9bcd257dea4e
children 09233b625cb9
line wrap: on
line source

module:set_global();


local modulemanager = require "core.modulemanager";

module:provides("http", {
	route = {
		GET = function()
			for host in pairs(prosody.hosts) do
				local mods = modulemanager.get_modules(host);
				for _, mod in pairs(mods) do
					if mod.module.status_type == "error" then
						return { status_code = 500; headers = { content_type = "text/plain" }; body = "HAS ERRORS\n" };
					end
				end
			end

			return { status_code = 200; headers = { content_type = "text/plain" }; body = "OK\n" };
		end;
	};
});