v0.1.30 - add public GET /health JSON endpoint with status version and uptime

This commit is contained in:
Your Name
2026-03-09 17:34:23 -04:00
parent d400744f68
commit b9e9a08e9e
4 changed files with 21 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -10,8 +10,8 @@
// Version information (auto-updated by build system)
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_PATCH 29
#define VERSION "v0.1.29"
#define VERSION_PATCH 30
#define VERSION "v0.1.30"
#include <stddef.h>
#include <stdint.h>

View File

@@ -27,6 +27,7 @@
// Shutdown flag set by signal handler - volatile sig_atomic_t is async-signal-safe
static volatile sig_atomic_t g_shutdown_requested = 0;
static time_t g_server_start_time = 0;
static void shutdown_handler(int signum) {
(void)signum;
@@ -2144,6 +2145,7 @@ int main(int argc, char *argv[]) {
// Initialize application logging
app_log(LOG_INFO, "=== Ginxsom FastCGI Application Starting ===");
app_log(LOG_INFO, "Process ID: %d", getpid());
g_server_start_time = time(NULL);
// Parse command line arguments
int use_test_keys = 0;
@@ -3061,6 +3063,23 @@ if (!config_loaded /* && !initialize_server_config() */) {
strcmp(request_uri, "/auth") == 0) {
// Handle GET /auth requests using the existing handler
handle_auth_challenge_request();
} else if (strcmp(request_method, "GET") == 0 &&
strcmp(request_uri, "/health") == 0) {
// Handle GET /health requests - simple public health response
time_t now = time(NULL);
long uptime_seconds = 0;
if (g_server_start_time > 0 && now >= g_server_start_time) {
uptime_seconds = (long)(now - g_server_start_time);
}
printf("Status: 200 OK\r\n");
printf("Content-Type: application/json\r\n\r\n");
printf("{\n");
printf(" \"status\": \"ok\",\n");
printf(" \"version\": \"%s\",\n", VERSION);
printf(" \"uptime\": %ld\n", uptime_seconds);
printf("}\n");
log_request("GET", "/health", "public", 200);
} else if (strcmp(request_method, "DELETE") == 0) {
// Handle DELETE /<sha256> requests with pre-validated auth
const char *sha256 = extract_sha256_from_uri(request_uri);