39void add_cors_headers(crow::response &res,
const rest_server_context &ctx) {
51 std::shared_ptr<rest_server_context> ctx) {
53 CROW_ROUTE(app,
"/api/v1/associations/active")
54 .methods(crow::HTTPMethod::GET)([ctx](
const crow::request & ) {
56 res.add_header(
"Content-Type",
"application/json");
57 add_cors_headers(res, *ctx);
59 if (!ctx->dicom_server) {
62 "DICOM server not configured");
66 auto stats = ctx->dicom_server->get_statistics();
67 auto active_count = ctx->dicom_server->active_associations();
68 auto uptime_sec = stats.uptime().count();
70 std::ostringstream oss;
71 oss << R
"({"active_count":)" << active_count
72 << R"(,"total_associations":)" << stats.total_associations
73 << R"(,"rejected_associations":)" << stats.rejected_associations
74 << R"(,"messages_processed":)" << stats.messages_processed
75 << R"(,"bytes_received":)" << stats.bytes_received
76 << R"(,"bytes_sent":)" << stats.bytes_sent
77 << R"(,"uptime_seconds":)" << uptime_sec
78 << R"(,"server_running":)"
79 << (ctx->dicom_server->is_running() ? "true" :
"false")
88 CROW_ROUTE(app,
"/api/v1/associations/<string>")
89 .methods(crow::HTTPMethod::DELETE)(
90 [ctx](
const crow::request & ,
91 const std::string &association_id) {
93 res.add_header(
"Content-Type",
"application/json");
94 add_cors_headers(res, *ctx);
96 if (association_id.empty()) {
99 "Association ID is required");
103 if (!ctx->dicom_server) {
106 "DICOM server not configured");
117 "Individual association termination is not supported. "
118 "Associations are managed by the DICOM server via idle "
119 "timeouts and graceful shutdown.");
124 CROW_ROUTE(app,
"/api/v1/associations/<string>")
125 .methods(crow::HTTPMethod::GET)(
126 [ctx](
const crow::request & ,
127 const std::string &association_id) {
129 res.add_header(
"Content-Type",
"application/json");
130 add_cors_headers(res, *ctx);
132 if (association_id.empty()) {
135 "Association ID is required");
139 if (!ctx->dicom_server) {
142 "DICOM server not configured");
152 "Individual association lookup is not supported. "
153 "Use GET /api/v1/associations/active for aggregate "