From cd59f14f9de567f2e84f88b3e70d4652ab1e5ea8 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Sat, 21 Feb 2026 18:59:19 +0100 Subject: Let the html layer fiddle with request --- src/html.c | 8 ++++---- src/html.h | 8 +++++--- src/web.c | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/html.c b/src/html.c index ec7064c..228e8ef 100644 --- a/src/html.c +++ b/src/html.c @@ -315,7 +315,7 @@ static const char *status_to_display(const char *status) { return status; } -char *html_render_clients_page(const char *host, const struct ListClientResult *result, size_t *out_len) { +char *html_render_clients_page(const struct Request *request, const struct ListClientResult *result, size_t *out_len) { // Count stale clients int stale_count = 0; for (int i = 0; i < result->clients_len; i++) { @@ -409,7 +409,7 @@ char *html_render_clients_page(const char *host, const struct ListClientResult * return buf; } -char *html_render_client_detail_page(const char *host, const char* proto, const struct GetClientOnlyResult *client_result, const struct GetBackupsResult *backups_result, size_t *out_len) { +char *html_render_client_detail_page(const struct Request *request, const struct GetClientOnlyResult *client_result, const struct GetBackupsResult *backups_result, size_t *out_len) { // Determine status and staleness int is_stale = 0; const char *current_status = "OK"; @@ -475,8 +475,8 @@ char *html_render_client_detail_page(const char *host, const char* proto, const " \n" " \n", client_result->secret, - proto != NULL ? proto : "http", - host != NULL ? host : "localhost", + request->proto != NULL ? request->proto : "http", + request->host != NULL ? request->host : "localhost", client_result->name, client_result->secret ); diff --git a/src/html.h b/src/html.h index d4aaea5..275f84e 100644 --- a/src/html.h +++ b/src/html.h @@ -1,18 +1,20 @@ #pragma once #include "app.h" +#include "web.h" #include +struct Request; + char *html_render_login_page(const char *error_msg, size_t *out_len); char *html_render_clients_page( - const char *host, + const struct Request *request, const struct ListClientResult *clients, size_t *out_len); char *html_render_client_detail_page( - const char *host, - const char *proto, + const struct Request *request, const struct GetClientOnlyResult *client, const struct GetBackupsResult *backups, size_t *out_len); diff --git a/src/web.c b/src/web.c index e85abaa..61393ad 100644 --- a/src/web.c +++ b/src/web.c @@ -453,7 +453,7 @@ static enum MHD_Result handler( // Render HTML size_t html_len; - char *html = html_render_clients_page(request->host, clients, &html_len); + char *html = html_render_clients_page(request, clients, &html_len); free(clients); if (!html) { @@ -521,7 +521,7 @@ static enum MHD_Result handler( // Render HTML size_t html_len; - char *html = html_render_client_detail_page(request->host, request->proto, &client_result, backups_result, &html_len); + char *html = html_render_client_detail_page(request, &client_result, backups_result, &html_len); free(backups_result); if (!html) { -- cgit v1.2.3