diff options
| author | Dmytro Ivanov <[email protected]> | 2025-04-23 10:54:22 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-04-23 10:54:22 +0200 |
| commit | 199553c86444dcd9c4cff91165938dbd9a5b4bbb (patch) | |
| tree | 017231616e164717b112dae1faab05f1d8573f10 /src/zenhttp/httpserver.cpp | |
| parent | make sure to call MakeSafeAbsolutePathÍnPlace where appropriate (#363) (diff) | |
| download | zen-199553c86444dcd9c4cff91165938dbd9a5b4bbb.tar.xz zen-199553c86444dcd9c4cff91165938dbd9a5b4bbb.zip | |
Make plugin loading errors non fatal (#364)
make plugin loading errors non fatal
Diffstat (limited to 'src/zenhttp/httpserver.cpp')
| -rw-r--r-- | src/zenhttp/httpserver.cpp | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp index d12f89a92..764f2a2a7 100644 --- a/src/zenhttp/httpserver.cpp +++ b/src/zenhttp/httpserver.cpp @@ -831,7 +831,6 @@ CreateHttpServerPlugin(const HttpServerPluginConfig& PluginConfig) const std::string& PluginName = PluginConfig.PluginName; ZEN_INFO("using '{}' plugin HTTP server implementation", PluginName) - Ref<HttpPluginServer> Server{CreateHttpPluginServer()}; if (PluginName.starts_with("builtin:"sv)) { @@ -845,28 +844,41 @@ CreateHttpServerPlugin(const HttpServerPluginConfig& PluginConfig) { Plugin = CreateAsioTransportPlugin(); } + else + { + ZEN_WARN("Unknown builtin plugin '{}'", PluginName) + return {}; + } + + ZEN_ASSERT(!Plugin.IsNull()); - if (!Plugin.IsNull()) + for (const std::pair<std::string, std::string>& Option : PluginConfig.PluginOptions) { - for (const std::pair<std::string, std::string>& Option : PluginConfig.PluginOptions) - { - Plugin->Configure(Option.first.c_str(), Option.second.c_str()); - } - Server->AddPlugin(Plugin); + Plugin->Configure(Option.first.c_str(), Option.second.c_str()); } + + Ref<HttpPluginServer> Server{CreateHttpPluginServer()}; + Server->AddPlugin(Plugin); + return Server; +# else + ZEN_WARN("Builtin plugin '{}' is not supported", PluginName) + return {}; # endif } - else + + Ref<DllTransportPlugin> DllPlugin{CreateDllTransportPlugin()}; + if (!DllPlugin->LoadDll(PluginName)) { - Ref<DllTransportPlugin> DllPlugin{CreateDllTransportPlugin()}; - DllPlugin->LoadDll(PluginName); - for (const std::pair<std::string, std::string>& Option : PluginConfig.PluginOptions) - { - DllPlugin->ConfigureDll(PluginName, Option.first.c_str(), Option.second.c_str()); - } - Server->AddPlugin(DllPlugin); + return {}; + } + + for (const std::pair<std::string, std::string>& Option : PluginConfig.PluginOptions) + { + DllPlugin->ConfigureDll(PluginName, Option.first.c_str(), Option.second.c_str()); } + Ref<HttpPluginServer> Server{CreateHttpPluginServer()}; + Server->AddPlugin(DllPlugin); return Server; } #endif @@ -888,7 +900,11 @@ CreateHttpServer(const HttpServerConfig& Config) for (const HttpServerPluginConfig& PluginConfig : Config.PluginConfigs) { - Server->AddServer(CreateHttpServerPlugin(PluginConfig)); + Ref<HttpServer> PluginServer = CreateHttpServerPlugin(PluginConfig); + if (!PluginServer.IsNull()) + { + Server->AddServer(PluginServer); + } } return Server; |