From c0ccf16c69d43a89674640c61d13ec2c02b128d6 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 10 Apr 2020 15:36:59 +0200 Subject: First working plugin: static-files --- plugin.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'plugin.cpp') diff --git a/plugin.cpp b/plugin.cpp index 8e4182c..db0632d 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -60,13 +60,25 @@ bool PluginLoader::validate_config() for (const auto& site: sites) { for (const auto& path: site.paths) { - if (path.type == Plugin) { - std::string plugin {path.params.at("plugin")}; + // path must contain target and plugin + auto it {path.params.find("target")}; + if (it == path.params.end()) { + std::cout << "Path " << path.requested << " for site " << site.name << " is missing target specification." << std::endl; + return false; + } - if (!m_plugins.contains(plugin)) { - std::cout << "Configured plugin " << plugin << " not found" << std::endl; - return false; - } + it = path.params.find("plugin"); + if (it == path.params.end()) { + std::cout << "Path " << path.requested << " for site " << site.name << " is missing plugin specification." << std::endl; + return false; + } + + std::string plugin {it->second}; + + // check if plugin exists + if (!m_plugins.contains(plugin)) { + std::cout << "Configured plugin " << plugin << " not found" << std::endl; + return false; } } } -- cgit v1.2.3