Fix code formatting

This commit is contained in:
Felix Kauselmann 2022-10-23 20:21:16 +02:00
parent 5ad5d52f05
commit f9c07707f3
3 changed files with 38 additions and 41 deletions

View File

@ -10,51 +10,50 @@
using stefanfrings::HttpRequest; using stefanfrings::HttpRequest;
using stefanfrings::HttpResponse; using stefanfrings::HttpResponse;
//using stefanfrings::HttpSession; // using stefanfrings::HttpSession;
using stefanfrings::Template; using stefanfrings::Template;
StatusPageController::StatusPageController() {} StatusPageController::StatusPageController() { }
void StatusPageController::service(HttpRequest &request, HttpResponse &response) void StatusPageController::service(HttpRequest &request, HttpResponse &response)
{ {
response.setHeader("Content-Type", "text/html; charset=utf-8"); response.setHeader("Content-Type", "text/html; charset=utf-8");
response.setHeader("Connection", "close"); response.setHeader("Connection", "close");
Template StatusPage = Template(QStringLiteral( Template StatusPage = Template(
"<!DOCTYPE html>\n" QStringLiteral(
"<html>\n" "<!DOCTYPE html>\n"
"<head>\n" "<html>\n"
"<title>YACReaderLibrary Server</title>\n" "<head>\n"
"</head>\n" "<title>YACReaderLibrary Server</title>\n"
"<body>\n\n" "</head>\n"
"<center>\n" "<body>\n\n"
"<img src='/images/webui/YACLibraryServer.svg' width=15%>\n" "<center>\n"
"<h1>YACReaderLibraryServer is up and running.</h1>\n" "<img src='/images/webui/YACLibraryServer.svg' width=15%>\n"
"<p>YACReader {yr.version}<p>\n" "<h1>YACReaderLibraryServer is up and running.</h1>\n"
"<p>Server {server.version}<p>\n" "<p>YACReader {yr.version}<p>\n"
"<p>OS:\t{os.name} {os.version}</p>\n" "<p>Server {server.version}<p>\n"
"<p>Port:\t{os.port}</p>\n" "<p>OS:\t{os.name} {os.version}</p>\n"
"<table>\n" "<p>Port:\t{os.port}</p>\n"
"<thead>\n" "<table>\n"
"<tr>\n" "<thead>\n"
"<th>Library</th>\n" "<tr>\n"
"<th>Path</th>\n" "<th>Library</th>\n"
"</tr>\n" "<th>Path</th>\n"
"</thead>\n" "</tr>\n"
"{loop Library}" "</thead>\n"
"<tr>\n" "{loop Library}"
"<td>{Library.Name}</td>\n" "<tr>\n"
"<td>{Library.Path}</td>\n" "<td>{Library.Name}</td>\n"
"<tr>\n" "<td>{Library.Path}</td>\n"
"{end Library}" "<tr>\n"
"</p>\n" "{end Library}"
"</center>\n" "</p>\n"
"</body>\n" "</center>\n"
"</html>\n" "</body>\n"
), "</html>\n"),
"StatusPage" "StatusPage");
);
StatusPage.enableWarnings(); StatusPage.enableWarnings();
@ -74,8 +73,7 @@ void StatusPageController::service(HttpRequest &request, HttpResponse &response)
// Fill template // Fill template
StatusPage.loop("Library", num_libs); StatusPage.loop("Library", num_libs);
for (size_t i = 0; i < num_libs; i++) for (size_t i = 0; i < num_libs; i++) {
{
StatusPage.setVariable(QString("Library%1.Name").arg(i), library_names.at(i)); StatusPage.setVariable(QString("Library%1.Name").arg(i), library_names.at(i));
StatusPage.setVariable(QString("Library%1.Path").arg(i), libraries.getPath(library_names.at(i))); StatusPage.setVariable(QString("Library%1.Path").arg(i), libraries.getPath(library_names.at(i)));
} }

View File

@ -10,7 +10,7 @@ class StatusPageController : public stefanfrings::HttpRequestHandler
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(StatusPageController); Q_DISABLE_COPY(StatusPageController);
public: public:
StatusPageController(); StatusPageController();
void service(stefanfrings::HttpRequest &request, stefanfrings::HttpResponse &response) override; void service(stefanfrings::HttpRequest &request, stefanfrings::HttpResponse &response) override;

View File

@ -160,8 +160,7 @@ void RequestMapper::service(HttpRequest &request, HttpResponse &response)
QLOG_TRACE() << "X-Request-Id: " << request.getHeader("x-request-id"); QLOG_TRACE() << "X-Request-Id: " << request.getHeader("x-request-id");
// Browsers ask for text/html // Browsers ask for text/html
if (path.startsWith("/webui")) if (path.startsWith("/webui")) {
{
serviceWebUI(request, response); serviceWebUI(request, response);
} else if (path.startsWith("/v2")) { } else if (path.startsWith("/v2")) {
serviceV2(request, response); serviceV2(request, response);