#include "dolog.hh"
#include "gettime.hh"
#include "threadname.hh"
-#include "sodcrypto.hh"
#include "sstuff.hh"
struct WebserverConfig
};
#endif /* DISABLE_PROMETHEUS */
+#ifndef DISABLE_WEB_CONFIG
static bool apiWriteConfigFile(const string& filebasename, const string& content)
{
if (!g_apiReadWrite) {
string content = "setACL({" + acl + "})";
apiWriteConfigFile("acl", content);
}
+#endif /* DISABLE_WEB_CONFIG */
static bool checkAPIKey(const YaHTTP::Request& req, const std::unique_ptr<CredentialsHolder>& apiKey)
{
using namespace json11;
+#ifndef DISABLE_BUILTIN_HTML
static void handleJSONStats(const YaHTTP::Request& req, YaHTTP::Response& resp)
{
handleCORS(req, resp);
resp.status = 404;
}
}
+#endif /* DISABLE_BUILTIN_HTML */
static void addServerToJSON(Json::array& servers, int id, const std::shared_ptr<DownstreamState>& a)
{
resp.headers["Content-Type"] = "application/json";
}
+#ifndef DISABLE_WEB_CONFIG
static void handleConfigDump(const YaHTTP::Request& req, YaHTTP::Response& resp)
{
handleCORS(req, resp);
resp.body = my_json.dump();
}
}
+#endif /* DISABLE_WEB_CONFIG */
static std::unordered_map<std::string, std::function<void(const YaHTTP::Request&, YaHTTP::Response&)>> s_webHandlers;
void registerBuiltInWebHandlers()
{
+#ifndef DISABLE_BUILTIN_HTML
registerWebHandler("/jsonstat", handleJSONStats);
+#endif /* DISABLE_BUILTIN_HTML */
#ifndef DISABLE_PROMETHEUS
registerWebHandler("/metrics", handlePrometheus);
#endif /* DISABLE_PROMETHEUS */
registerWebHandler("/api/v1/servers/localhost", handleStats);
registerWebHandler("/api/v1/servers/localhost/pool", handlePoolStats);
registerWebHandler("/api/v1/servers/localhost/statistics", handleStatsOnly);
+#ifndef DISABLE_WEB_CONFIG
registerWebHandler("/api/v1/servers/localhost/config", handleConfigDump);
registerWebHandler("/api/v1/servers/localhost/config/allow-from", handleAllowFrom);
+#endif /* DISABLE_WEB_CONFIG */
#ifndef DISABLE_BUILTIN_HTML
registerWebHandler("/", redirectToIndex);