diff --git a/include/cell/requirements b/include/cell/requirements index d6c0562..7c757fe 100755 --- a/include/cell/requirements +++ b/include/cell/requirements @@ -1,12 +1,3 @@ #include "common.hpp" #include "prestructure.hpp" #include "core/core.hpp" -//#include "core/configuration.hpp" -//#include "core/terminal.hpp" -//#include "core/console.hpp" -//#include "core/database.hpp" -//#include "core/version.hpp" -//#include "core/logger.hpp" -//#include "core/setting.hpp" -//#include "translator/translator.hpp" -//#include "translator/language.hpp" diff --git a/source/abstracts/modules/webserver/virtualhost.hpp b/source/abstracts/modules/webserver/virtualhost.hpp index f7598aa..d917537 100644 --- a/source/abstracts/modules/webserver/virtualhost.hpp +++ b/source/abstracts/modules/webserver/virtualhost.hpp @@ -264,9 +264,14 @@ class __cell_export VirtualHostConfig __cell_virtual void setLogFile(const std::string& filePath) = __cell_zero; /** - * @brief Enable or disable monitoring functionality + * @brief Enable monitoring functionality */ __cell_virtual void enableMonitoring() = __cell_zero; + + + /** + * @brief Disable monitoring functionality + */ __cell_virtual void disableMonitoring() = __cell_zero; /** diff --git a/source/core/core-meta.hpp b/source/core/core-meta.hpp index 9649c48..767a198 100644 --- a/source/core/core-meta.hpp +++ b/source/core/core-meta.hpp @@ -25,8 +25,6 @@ # error "Cell's "core-concepts.hpp" was not found!" #endif -CELL_USING_NAMESPACE Cell::Concepts; - CELL_NAMESPACE_BEGIN(Cell::Meta) /** @@ -181,16 +179,16 @@ class MetaEngine { template std::string applyFixedPrecision(T value, int precision = 0) { - if constexpr (FloatingPoint) { + if constexpr (Concepts::FloatingPoint) { std::ostringstream oss; oss << std::fixed << std::setprecision(precision) << value; return oss.str(); - } else if constexpr (ConvertibleToString) { + } else if constexpr (Concepts::ConvertibleToString) { std::ostringstream oss; oss << value; return oss.str(); } else { - static_assert(FloatingPoint || ConvertibleToString, "Unsupported type"); + static_assert(Concepts::FloatingPoint || Concepts::ConvertibleToString, "Unsupported type"); } } @@ -203,7 +201,7 @@ class MetaEngine { * @param str The string-like object. * @return const char* Pointer to the underlying character data of the string. */ - template + template const char* returnView(const T& str) { return str.data(); diff --git a/source/core/format.hpp b/source/core/format.hpp index 0a1fb83..5005d9f 100755 --- a/source/core/format.hpp +++ b/source/core/format.hpp @@ -29,7 +29,6 @@ class Format { public: template static std::string print(const std::string& formatString, const Args&... args) { - #ifdef USE_BOOST_FORMAT boost::format formatter(convertPlaceholders(formatString)); try { diff --git a/source/core/linkparser.cpp b/source/core/linkparser.cpp index b7afcaa..6503ced 100755 --- a/source/core/linkparser.cpp +++ b/source/core/linkparser.cpp @@ -20,8 +20,8 @@ LinkParser::~LinkParser() void LinkParser::parse(std::string& url) { std::size_t pos = std::string::npos; - std::string http = "http://"; - std::string https = "https://"; + std::string http = CELL_PROTOCOL_HTTP; + std::string https = CELL_PROTOCOL_HTTPS; // Search for the substring in string in a loop untill nothing is found while((pos = url.find(http))!= std::string::npos || (pos = url.find(https))!= std::string::npos) { diff --git a/source/modules/network/http/httprequest.hpp b/source/modules/network/http/httprequest.hpp index 3606e8a..edbfcee 100755 --- a/source/modules/network/http/httprequest.hpp +++ b/source/modules/network/http/httprequest.hpp @@ -152,7 +152,7 @@ enum class HTTP_METHOD { * 205 Reset Content The request has been successfully processed, but is not returning any content, and requires that the requester reset the document view * 206 Partial Content The server is delivering only part of the resource due to a range header sent by the client */ -enum class HTTP_MESSAGE_SUCCESS +enum HTTP_MESSAGE_SUCCESS : Types::u8 { Ok = 200, //!< OK Created = 201, //!< Created @@ -177,7 +177,7 @@ enum class HTTP_MESSAGE_SUCCESS * 307 Temporary Redirect The requested page has moved temporarily to a new URL * 308 Resume Incomplete Used in the resumable requests proposal to resume aborted PUT or POST requests */ -enum class HTTP_MESSAGE_REDIRECTION +enum HTTP_MESSAGE_REDIRECTION { MultipleChoices = 300, MovedPermanently = 301, diff --git a/source/modules/network/webserver/ratelimiter.cpp b/source/modules/network/webserver/ratelimiter.cpp index fc3b01b..4cc1da7 100644 --- a/source/modules/network/webserver/ratelimiter.cpp +++ b/source/modules/network/webserver/ratelimiter.cpp @@ -5,6 +5,7 @@ #endif CELL_USING_NAMESPACE Cell; + CELL_USING_NAMESPACE Cell::Types; CELL_NAMESPACE_BEGIN(Cell::Modules::BuiltIn::Network::WebServer) diff --git a/source/modules/network/webserver/response.cpp b/source/modules/network/webserver/response.cpp index 5ec927f..569baeb 100644 --- a/source/modules/network/webserver/response.cpp +++ b/source/modules/network/webserver/response.cpp @@ -37,9 +37,9 @@ void Response::setStatusCode(int statusCode) m_responseStructure.statusCode = statusCode; } -void Response::setContentType(const std::string& contentType) +void Response::setContentType(std::string_view contentType) { - m_responseStructure.contentType = contentType; + m_responseStructure.contentType = contentType.data(); } void Response::setContent(const std::string& content) diff --git a/source/modules/network/webserver/response.hpp b/source/modules/network/webserver/response.hpp index 7942e69..8820ac8 100644 --- a/source/modules/network/webserver/response.hpp +++ b/source/modules/network/webserver/response.hpp @@ -85,7 +85,7 @@ class __cell_export Response { * @brief Set the content type of the response. * @param content_type The content type to set. */ - void setContentType(const std::string& content_type); + void setContentType(std::string_view contentType); /** * @brief Set the content of the response. diff --git a/source/modules/network/webserver/router.cpp b/source/modules/network/webserver/router.cpp index 4f6a478..275b51e 100644 --- a/source/modules/network/webserver/router.cpp +++ b/source/modules/network/webserver/router.cpp @@ -23,6 +23,16 @@ void Router::addRoute(const std::string& path, const Handler& handler, const std m_routes[methodKey][normalizedPath] = handler; } +void Router::addRoute(const std::vector& paths, const Handler& handler, const std::string& method) +{ + std::string methodKey = normalizeMethod(method).value(); + + for (const std::string& path : paths) { + std::string normalizedPath = normalizePath(path).value(); + m_routes[methodKey][normalizedPath] = handler; + } +} + void Router::addMiddleware(const Middleware& middleware) { m_middleWares.push_back(middleware); diff --git a/source/modules/network/webserver/router.hpp b/source/modules/network/webserver/router.hpp index 0953769..ee088d6 100644 --- a/source/modules/network/webserver/router.hpp +++ b/source/modules/network/webserver/router.hpp @@ -15,14 +15,14 @@ #ifndef CELL_ROUTER_HPP #define CELL_ROUTER_HPP -//! Cell's Core (Basic Requirements). -#if __has_include() -# include +#ifdef __has_include +# if __has_include("core/core.hpp") +# include "core/core.hpp" #else -# error "Cell's requirements was not found!" +# error "Cell's "core/core.hpp" was not found!" +# endif #endif - #ifdef __has_include # if __has_include("request.hpp") # include "request.hpp" @@ -61,6 +61,8 @@ class __cell_export Router { */ void addRoute(const std::string& path, const Handler& handler, const std::string& method = "GET"); + void addRoute(const std::vector& paths, const Handler& handler, const std::string& method = "GET"); + /** * Add a middleware to the router. * diff --git a/source/modules/network/webserver/webserver.hpp b/source/modules/network/webserver/webserver.hpp index 3251e39..e0f9055 100644 --- a/source/modules/network/webserver/webserver.hpp +++ b/source/modules/network/webserver/webserver.hpp @@ -13,14 +13,6 @@ #ifndef CELL_WEBSERVER_HPP #define CELL_WEBSERVER_HPP -#ifdef __has_include -# if __has_include("common.hpp") -# include "common.hpp" -#else -# error "Cell's "common.hpp" was not found!" -# endif -#endif - #ifdef __has_include # if __has_include("abstracts/modules/webserver/webserver.hpp") # include "abstracts/modules/webserver/webserver.hpp"