Enhance code formatting and organization:
- Add tasks for code formatting and checking in VSCode - Update .clang-format for consistent style - Clean up includes and formatting in various files
This commit is contained in:
parent
31014705b1
commit
3eb46dba13
@ -35,4 +35,7 @@ AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
|
||||
# Add empty line between function definitions
|
||||
SeparateDefinitionBlocks: Always
|
||||
28
.vscode/tasks.json
vendored
28
.vscode/tasks.json
vendored
@ -67,6 +67,34 @@
|
||||
"dependsOn": "Build ASAN",
|
||||
"detail": "Build and run AddressSanitizer version"
|
||||
},
|
||||
{
|
||||
"label": "Format Code",
|
||||
"type": "shell",
|
||||
"command": "find webserv -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i",
|
||||
"group": "build",
|
||||
"detail": "Format all C++ source and header files using clang-format",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Check Format",
|
||||
"type": "shell",
|
||||
"command": "find webserv -name '*.cpp' -o -name '*.hpp' | xargs clang-format --dry-run --Werror",
|
||||
"group": "test",
|
||||
"detail": "Check if all files are properly formatted (without modifying them)",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "shared"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Clean",
|
||||
"type": "shell",
|
||||
|
||||
@ -3,8 +3,9 @@
|
||||
#include "webserv/socket/Socket.hpp"
|
||||
|
||||
#include <webserv/config/ServerConfig.hpp>
|
||||
#include <webserv/server/Server.hpp>
|
||||
#include <webserv/http/HttpRequest.hpp>
|
||||
#include <webserv/server/Server.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Server;
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class ConfigManager
|
||||
{
|
||||
public:
|
||||
@ -16,7 +15,8 @@ class ConfigManager
|
||||
|
||||
void init(const std::string &filePath);
|
||||
static ConfigManager &getInstance();
|
||||
const std::vector<ServerConfig> &getServerConfigs() const { return serverConfigs_; }
|
||||
|
||||
[[nodiscard]] const std::vector<ServerConfig> &getServerConfigs() const { return serverConfigs_; }
|
||||
|
||||
private:
|
||||
bool initialized_;
|
||||
|
||||
@ -14,6 +14,7 @@ void LocationConfig::parseLocationBlock(const std::string &block)
|
||||
{
|
||||
parseDirectives(block);
|
||||
}
|
||||
|
||||
void LocationConfig::parseDirectives(const std::string &declarations)
|
||||
{
|
||||
std::istringstream stream(declarations);
|
||||
|
||||
@ -12,16 +12,24 @@ class ServerConfig
|
||||
ServerConfig(const std::string &serverBlock);
|
||||
|
||||
[[nodiscard]] const std::string &getHost() const { return host_; }
|
||||
|
||||
[[nodiscard]] int getPort() const { return port_; }
|
||||
|
||||
[[nodiscard]] const std::string &getRoot() const { return root_; }
|
||||
|
||||
[[nodiscard]] const std::string &getCgiPass() const { return cgi_pass_; }
|
||||
|
||||
[[nodiscard]] const std::string &getCgiExt() const { return cgi_ext_; }
|
||||
|
||||
[[nodiscard]] const std::map<int, std::string> &getErrorPages() const { return error_page_; }
|
||||
|
||||
[[nodiscard]] const std::vector<std::string> &getIndexFiles() const { return index_files_; }
|
||||
|
||||
[[nodiscard]] const LocationConfig &getLocation(const std::string &path) const;
|
||||
[[nodiscard]] std::vector<std::string> getLocationPaths() const;
|
||||
|
||||
void setServerFD(int fd) { server_fd_ = fd; }
|
||||
|
||||
[[nodiscard]] int getServerFD() const { return server_fd_; }
|
||||
|
||||
private:
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
#include <webserv/client/Client.hpp>
|
||||
#include <webserv/config/ServerConfig.hpp>
|
||||
#include <webserv/http/HttpConstants.hpp>
|
||||
#include <webserv/http/HttpRequest.hpp>
|
||||
#include <webserv/log/Log.hpp>
|
||||
#include <webserv/config/ServerConfig.hpp>
|
||||
#include <webserv/client/Client.hpp>
|
||||
#include <webserv/http/HttpConstants.hpp>
|
||||
|
||||
HttpRequest::HttpRequest(const ServerConfig *serverConfig, const Client *client)
|
||||
: serverConfig_(serverConfig), client_(client)
|
||||
{
|
||||
Log::trace("HttpRequest constructor called");
|
||||
}
|
||||
|
||||
HttpRequest::~HttpRequest()
|
||||
{
|
||||
Log::trace("HttpRequest destructor called");
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include <string>
|
||||
|
||||
class Client;
|
||||
|
||||
class HttpRequest
|
||||
{
|
||||
public:
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
#include <webserv/http/HttpResponse.hpp>
|
||||
|
||||
HttpResponse::HttpResponse()
|
||||
{
|
||||
}
|
||||
HttpResponse::HttpResponse() {}
|
||||
|
||||
@ -4,4 +4,4 @@ class HttpResponse
|
||||
{
|
||||
public:
|
||||
HttpResponse();
|
||||
};
|
||||
};
|
||||
@ -18,7 +18,7 @@ int main(int argc, char **argv)
|
||||
Log::setFileChannel("webserv.log", std::ios_base::app, Log::Level::Trace);
|
||||
Log::setStdoutChannel(Log::Level::Trace);
|
||||
Log::info("\n======================\nStarting webserv...\n======================\n");
|
||||
Log::warning("Testing context", {{ "key1", "value1"}, {"key2", "value2"}});
|
||||
Log::warning("Testing context", {{"key1", "value1"}, {"key2", "value2"}});
|
||||
ConfigManager::getInstance().init(argv[1]); // NOLINT
|
||||
Server server(ConfigManager::getInstance());
|
||||
server.start();
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
#include <webserv/router/Router.hpp>
|
||||
|
||||
Router::Router()
|
||||
{
|
||||
}
|
||||
Router::Router() {}
|
||||
|
||||
@ -7,5 +7,4 @@ class Router
|
||||
{
|
||||
public:
|
||||
Router();
|
||||
|
||||
};
|
||||
@ -54,6 +54,7 @@ void Socket::listen(int backlog) const
|
||||
throw std::runtime_error("Listen failed");
|
||||
}
|
||||
}
|
||||
|
||||
void Socket::bind(const std::string &host, const int port) const
|
||||
{
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user