Skip to content

Commit 2116ef4

Browse files
committed
Some new changes.
1 parent 0d43e8c commit 2116ef4

File tree

12 files changed

+35
-37
lines changed

12 files changed

+35
-37
lines changed

include/cell/requirements

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
11
#include "common.hpp"
22
#include "prestructure.hpp"
33
#include "core/core.hpp"
4-
//#include "core/configuration.hpp"
5-
//#include "core/terminal.hpp"
6-
//#include "core/console.hpp"
7-
//#include "core/database.hpp"
8-
//#include "core/version.hpp"
9-
//#include "core/logger.hpp"
10-
//#include "core/setting.hpp"
11-
//#include "translator/translator.hpp"
12-
//#include "translator/language.hpp"

source/abstracts/modules/webserver/virtualhost.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,14 @@ class __cell_export VirtualHostConfig
264264
__cell_virtual void setLogFile(const std::string& filePath) = __cell_zero;
265265

266266
/**
267-
* @brief Enable or disable monitoring functionality
267+
* @brief Enable monitoring functionality
268268
*/
269269
__cell_virtual void enableMonitoring() = __cell_zero;
270+
271+
272+
/**
273+
* @brief Disable monitoring functionality
274+
*/
270275
__cell_virtual void disableMonitoring() = __cell_zero;
271276

272277
/**

source/core/core-meta.hpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
# error "Cell's "core-concepts.hpp" was not found!"
2626
#endif
2727

28-
CELL_USING_NAMESPACE Cell::Concepts;
29-
3028
CELL_NAMESPACE_BEGIN(Cell::Meta)
3129

3230
/**
@@ -181,16 +179,16 @@ class MetaEngine {
181179
template <typename T>
182180
std::string applyFixedPrecision(T value, int precision = 0)
183181
{
184-
if constexpr (FloatingPoint<T>) {
182+
if constexpr (Concepts::FloatingPoint<T>) {
185183
std::ostringstream oss;
186184
oss << std::fixed << std::setprecision(precision) << value;
187185
return oss.str();
188-
} else if constexpr (ConvertibleToString<T>) {
186+
} else if constexpr (Concepts::ConvertibleToString<T>) {
189187
std::ostringstream oss;
190188
oss << value;
191189
return oss.str();
192190
} else {
193-
static_assert(FloatingPoint<T> || ConvertibleToString<T>, "Unsupported type");
191+
static_assert(Concepts::FloatingPoint<T> || Concepts::ConvertibleToString<T>, "Unsupported type");
194192
}
195193
}
196194

@@ -203,7 +201,7 @@ class MetaEngine {
203201
* @param str The string-like object.
204202
* @return const char* Pointer to the underlying character data of the string.
205203
*/
206-
template <ConvertibleToStringView T>
204+
template <Concepts::ConvertibleToStringView T>
207205
const char* returnView(const T& str)
208206
{
209207
return str.data();

source/core/format.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class Format {
2929
public:
3030
template <typename... Args>
3131
static std::string print(const std::string& formatString, const Args&... args) {
32-
3332
#ifdef USE_BOOST_FORMAT
3433
boost::format formatter(convertPlaceholders(formatString));
3534
try {

source/core/linkparser.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ LinkParser::~LinkParser()
2020
void LinkParser::parse(std::string& url)
2121
{
2222
std::size_t pos = std::string::npos;
23-
std::string http = "http://";
24-
std::string https = "https://";
23+
std::string http = CELL_PROTOCOL_HTTP;
24+
std::string https = CELL_PROTOCOL_HTTPS;
2525
// Search for the substring in string in a loop untill nothing is found
2626
while((pos = url.find(http))!= std::string::npos || (pos = url.find(https))!= std::string::npos)
2727
{

source/modules/network/http/httprequest.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ enum class HTTP_METHOD {
152152
* 205 Reset Content The request has been successfully processed, but is not returning any content, and requires that the requester reset the document view
153153
* 206 Partial Content The server is delivering only part of the resource due to a range header sent by the client
154154
*/
155-
enum class HTTP_MESSAGE_SUCCESS
155+
enum HTTP_MESSAGE_SUCCESS : Types::u8
156156
{
157157
Ok = 200, //!< OK
158158
Created = 201, //!< Created
@@ -177,7 +177,7 @@ enum class HTTP_MESSAGE_SUCCESS
177177
* 307 Temporary Redirect The requested page has moved temporarily to a new URL
178178
* 308 Resume Incomplete Used in the resumable requests proposal to resume aborted PUT or POST requests
179179
*/
180-
enum class HTTP_MESSAGE_REDIRECTION
180+
enum HTTP_MESSAGE_REDIRECTION
181181
{
182182
MultipleChoices = 300,
183183
MovedPermanently = 301,

source/modules/network/webserver/ratelimiter.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#endif
66

77
CELL_USING_NAMESPACE Cell;
8+
89
CELL_USING_NAMESPACE Cell::Types;
910

1011
CELL_NAMESPACE_BEGIN(Cell::Modules::BuiltIn::Network::WebServer)

source/modules/network/webserver/response.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ void Response::setStatusCode(int statusCode)
3737
m_responseStructure.statusCode = statusCode;
3838
}
3939

40-
void Response::setContentType(const std::string& contentType)
40+
void Response::setContentType(std::string_view contentType)
4141
{
42-
m_responseStructure.contentType = contentType;
42+
m_responseStructure.contentType = contentType.data();
4343
}
4444

4545
void Response::setContent(const std::string& content)

source/modules/network/webserver/response.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class __cell_export Response {
8585
* @brief Set the content type of the response.
8686
* @param content_type The content type to set.
8787
*/
88-
void setContentType(const std::string& content_type);
88+
void setContentType(std::string_view contentType);
8989

9090
/**
9191
* @brief Set the content of the response.

source/modules/network/webserver/router.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ void Router::addRoute(const std::string& path, const Handler& handler, const std
2323
m_routes[methodKey][normalizedPath] = handler;
2424
}
2525

26+
void Router::addRoute(const std::vector<std::string>& paths, const Handler& handler, const std::string& method)
27+
{
28+
std::string methodKey = normalizeMethod(method).value();
29+
30+
for (const std::string& path : paths) {
31+
std::string normalizedPath = normalizePath(path).value();
32+
m_routes[methodKey][normalizedPath] = handler;
33+
}
34+
}
35+
2636
void Router::addMiddleware(const Middleware& middleware)
2737
{
2838
m_middleWares.push_back(middleware);

source/modules/network/webserver/router.hpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
#ifndef CELL_ROUTER_HPP
1616
#define CELL_ROUTER_HPP
1717

18-
//! Cell's Core (Basic Requirements).
19-
#if __has_include(<requirements>)
20-
# include <requirements>
18+
#ifdef __has_include
19+
# if __has_include("core/core.hpp")
20+
# include "core/core.hpp"
2121
#else
22-
# error "Cell's requirements was not found!"
22+
# error "Cell's "core/core.hpp" was not found!"
23+
# endif
2324
#endif
2425

25-
2626
#ifdef __has_include
2727
# if __has_include("request.hpp")
2828
# include "request.hpp"
@@ -61,6 +61,8 @@ class __cell_export Router {
6161
*/
6262
void addRoute(const std::string& path, const Handler& handler, const std::string& method = "GET");
6363

64+
void addRoute(const std::vector<std::string>& paths, const Handler& handler, const std::string& method = "GET");
65+
6466
/**
6567
* Add a middleware to the router.
6668
*

source/modules/network/webserver/webserver.hpp

-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
#ifndef CELL_WEBSERVER_HPP
1414
#define CELL_WEBSERVER_HPP
1515

16-
#ifdef __has_include
17-
# if __has_include("common.hpp")
18-
# include "common.hpp"
19-
#else
20-
# error "Cell's "common.hpp" was not found!"
21-
# endif
22-
#endif
23-
2416
#ifdef __has_include
2517
# if __has_include("abstracts/modules/webserver/webserver.hpp")
2618
# include "abstracts/modules/webserver/webserver.hpp"

0 commit comments

Comments
 (0)