formatting

This commit is contained in:
Quinten 2025-10-29 15:51:32 +01:00
parent e1e3003d94
commit e34205bd39

View File

@ -87,40 +87,39 @@ void Client::request()
Log::info("Received request: " + httpRequest_->getHttpVersion() + " " + httpRequest_->getMethod() + " " Log::info("Received request: " + httpRequest_->getHttpVersion() + " " + httpRequest_->getMethod() + " "
+ httpRequest_->getTarget() + " "); + httpRequest_->getTarget() + " ");
Log::debug("Request details", Log::debug("Request details", {
{ {"request_method", httpRequest_->getMethod()},
{"request_method", httpRequest_->getMethod()}, {"request_target", httpRequest_->getTarget()},
{"request_target", httpRequest_->getTarget()}, {"http_version", httpRequest_->getHttpVersion()},
{"http_version", httpRequest_->getHttpVersion()}, {"headers", httpRequest_->getHeaders().toString()},
{"headers", httpRequest_->getHeaders().toString()}, // {"body", httpRequest_->getBody()},
{"body", httpRequest_->getBody()}, {"state", std::to_string(static_cast<uint8_t>(httpRequest_->getState()))},
{"state", std::to_string(static_cast<uint8_t>(httpRequest_->getState()))}, });
});
try try
{ {
// Thoughts: if a handler isn't returned, this could because of the error handler already setting // Thoughts: if a handler isn't returned, this could because of the error handler already setting
// up the response so, maybe we don't need to throw a 500 when no handler. Because that would // up the response so, maybe we don't need to throw a 500 when no handler. Because that would
// override the actual error response. How about the router, or a handler, throws an exception if // override the actual error response. How about the router, or a handler, throws an exception if
// something goes wrong, and we catch it here to make a 500 response? // something goes wrong, and we catch it here to make a 500 response?
handler_ = router_->handleRequest(); handler_ = router_->handleRequest();
if (handler_ != nullptr) if (handler_ != nullptr)
{ {
handler_->handle(); handler_->handle();
} }
} }
catch (const RequestValidator::ValidationException &e) catch (const RequestValidator::ValidationException &e)
{ {
Log::error("Validation Exception during request handling: " + std::string(e.what())); Log::error("Validation Exception during request handling: " + std::string(e.what()));
ErrorHandler::createErrorResponse(e.code(), *httpResponse_); ErrorHandler::createErrorResponse(e.code(), *httpResponse_);
return; return;
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
Log::error("Exception during request handling: " + std::string(e.what())); Log::error("Exception during request handling: " + std::string(e.what()));
ErrorHandler::createErrorResponse(500, *httpResponse_); ErrorHandler::createErrorResponse(500, *httpResponse_);
return; return;
} }
} }
else else
{ {
@ -200,4 +199,5 @@ std::string Client::getClientAddress() const noexcept
return ""; return "";
} }
// NOLINTEND // NOLINTEND