分离 http依赖

This commit is contained in:
2026-08-06 21:33:46 +08:00
parent f060662ffd
commit 14b0b0e3bc
17 changed files with 1486 additions and 514 deletions
+3 -2
View File
@@ -12,11 +12,12 @@ Radio_State make_radio_state(Radio_Mode mode, int port, int buffer_count, int lo
return result;
}
}
Server_App::Server_App(int port, std::filesystem::path frontend_dist, std::filesystem::path config_file) : port_(port), frontend_dist_(std::move(frontend_dist)), config_store_(std::move(config_file)), state_resource_("/admin/radio_states", make_radio_states(), "/admin/status"), service_config_resource_(config_store_.data().radio_service, "/admin/config/radio", [this](const Radio_Service_Config& value) {
Server_App::Server_App(int port, std::filesystem::path frontend_dist, std::filesystem::path config_file) : port_(port), frontend_dist_(std::move(frontend_dist)), config_store_(std::move(config_file)), state_resource_("/admin/radio_states", make_radio_states()), service_config_resource_(config_store_.data().radio_service, "/admin/config/radio", [this](const Radio_Service_Config& value) {
config_store_.persist_radio_service(value);
}, &config_store_.mutex()), alert_config_resource_(config_store_.data().alerts, "/admin/config/alerts", [this](const Alert_Config& value) {
config_store_.persist_alerts(value);
}, &config_store_.mutex()), device_tables_(config_store_) {
state_resource_.register_overview_status<Server_Status>("/admin/status", 2000);
state_resource_.register_status<&Radio_State::status>(2000);
bind_routes();
}
@@ -69,7 +70,7 @@ void Server_App::bind_routes() {
status.poll_sequence = poll_sequence_.fetch_add(1, std::memory_order_relaxed) + 1;
status.radio_state_count = state_resource_.size();
status.listen_port = port_;
write_http_json(response, Json{{"status", 0}, {"msg", ""}, {"data", to_frontend_json(status)}});
write_http_json(response, Json{{"status", 0}, {"msg", ""}, {"data", to_status_json<Json>(status)}});
});
}
}