Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
Loading...
Searching...
No Matches
admin.c File Reference

Unified administration and monitoring controller implementation. More...

#include "csilk/app/admin.h"
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "cJSON.h"
#include "csilk/core/internal.h"
Include dependency graph for admin.c:

Functions

uint64_t atomic_load_http_requests (void)
 
uint64_t atomic_load_http_duration (void)
 
static void admin_ui_handler (csilk_ctx_t *c)
 Helper to serve the admin UI HTML.
 
static void admin_stats_handler (csilk_ctx_t *c)
 Aggregates system-wide statistics into a JSON response.
 
static void admin_topology_handler (csilk_ctx_t *c)
 Returns the router topology for graph visualization.
 
static void admin_profiler_handler (csilk_ctx_t *c)
 Simple profiler placeholder (Flamegraph data source).
 
static void admin_ws_handler (csilk_ctx_t *c)
 WebSocket handler that streams multiplexed events.
 
void csilk_admin_serve (csilk_app_t *app, const char *app_path)
 Register administration routes to an application.
 
void csilk_admin_serve_secure (csilk_app_t *app, const char *app_path, csilk_handler_t auth_middleware)
 Register administration routes with a secure middleware.
 

Variables

static uint64_t last_req_count = 0
 
static uint64_t last_check_time = 0
 

Detailed Description

Unified administration and monitoring controller implementation.

Function Documentation

◆ admin_profiler_handler()

static void admin_profiler_handler ( csilk_ctx_t *  c)
static

Simple profiler placeholder (Flamegraph data source).

◆ admin_stats_handler()

static void admin_stats_handler ( csilk_ctx_t *  c)
static

Aggregates system-wide statistics into a JSON response.

◆ admin_topology_handler()

static void admin_topology_handler ( csilk_ctx_t *  c)
static

Returns the router topology for graph visualization.

◆ admin_ui_handler()

static void admin_ui_handler ( csilk_ctx_t *  c)
static

Helper to serve the admin UI HTML.

◆ admin_ws_handler()

static void admin_ws_handler ( csilk_ctx_t *  c)
static

WebSocket handler that streams multiplexed events.

◆ atomic_load_http_duration()

uint64_t atomic_load_http_duration ( void  )
extern

◆ atomic_load_http_requests()

uint64_t atomic_load_http_requests ( void  )
extern

◆ csilk_admin_serve()

void csilk_admin_serve ( csilk_app_t *  app,
const char *  path 
)

Register administration routes to an application.

This function registers several routes under the given path:

  • GET <path> : Serves the HTML dashboard UI.
  • GET <path>/stats : Returns a JSON snapshot of all system metrics.
  • GET <path>/ws : WebSocket endpoint for real-time event streaming.
Parameters
appThe application handle.
pathThe base URL path for the admin panel (e.g., "/admin").
Note
Requires the server to be running and WebSocket support enabled.

◆ csilk_admin_serve_secure()

void csilk_admin_serve_secure ( csilk_app_t *  app,
const char *  app_path,
csilk_handler_t  auth_middleware 
)

Register administration routes with a secure middleware.

Register protected administration routes to an application.

This implementation creates a new route group for the admin panel, applying an optional authentication middleware. This ensures that sensitive metrics and real-time data are only accessible to authorized users.

Parameters
appThe high-level application handle.
app_pathThe base URL path for the admin panel (e.g., "/admin").
auth_middlewareOptional handler function for authentication.

Variable Documentation

◆ last_check_time

uint64_t last_check_time = 0
static

◆ last_req_count

uint64_t last_req_count = 0
static