//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2016 ArangoDB GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Dr. Frank Celler //////////////////////////////////////////////////////////////////////////////// #ifndef APPLICATION_FEATURES_GENERAL_SERVER_FEATURE_H #define APPLICATION_FEATURES_GENERAL_SERVER_FEATURE_H 1 #include "ApplicationFeatures/ApplicationFeature.h" #include "Aql/QueryRegistry.h" #include "Cluster/TraverserEngineRegistry.h" #include "GeneralServer/AsyncJobManager.h" #include "GeneralServer/GeneralServer.h" #include "GeneralServer/RestHandlerFactory.h" namespace arangodb { class RestServerThread; class GeneralServerFeature final : public application_features::ApplicationFeature { public: static rest::RestHandlerFactory* HANDLER_FACTORY; static rest::AsyncJobManager* JOB_MANAGER; public: static double keepAliveTimeout() { return GENERAL_SERVER != nullptr ? GENERAL_SERVER->_keepAliveTimeout : 300.0; }; static bool hasProxyCheck() { return GENERAL_SERVER != nullptr && GENERAL_SERVER->proxyCheck(); } static std::vector getTrustedProxies() { if (GENERAL_SERVER == nullptr) { return std::vector(); } return GENERAL_SERVER->trustedProxies(); } static bool allowMethodOverride() { if (GENERAL_SERVER == nullptr) { return false; } return GENERAL_SERVER->_allowMethodOverride; } static std::vector const& accessControlAllowOrigins() { static std::vector empty; if (GENERAL_SERVER == nullptr) { return empty; } return GENERAL_SERVER->_accessControlAllowOrigins; } private: static GeneralServerFeature* GENERAL_SERVER; public: explicit GeneralServerFeature(application_features::ApplicationServer& server); void collectOptions(std::shared_ptr) override final; void validateOptions(std::shared_ptr) override final; void prepare() override final; void start() override final; void beginShutdown() override final; void stop() override final; void unprepare() override final; bool proxyCheck() const { return _proxyCheck; } std::vector trustedProxies() const { return _trustedProxies; } private: void buildServers(); void defineHandlers(); private: double _keepAliveTimeout = 300.0; bool _allowMethodOverride; bool _proxyCheck; std::vector _trustedProxies; std::vector _accessControlAllowOrigins; std::unique_ptr _handlerFactory; std::unique_ptr _jobManager; std::unique_ptr> _combinedRegistries; std::vector> _servers; uint64_t _numIoThreads; }; } // namespace arangodb #endif