|
19 | 19 | #include <vix/config/Config.hpp> |
20 | 20 | #include <vix/utils/ServerPrettyLogs.hpp> |
21 | 21 | #include <vix/experimental/ThreadPoolExecutor.hpp> |
| 22 | +#include <vix/console.hpp> |
22 | 23 |
|
23 | | -// WebSocket OpenAPI docs (router-based) |
24 | 24 | #include <vix/websocket/openapi_docs.hpp> |
| 25 | +#include <vix/openapi/register_docs.hpp> |
25 | 26 |
|
26 | 27 | #include <atomic> |
27 | 28 | #include <chrono> |
@@ -137,20 +138,28 @@ namespace vix |
137 | 138 | */ |
138 | 139 | inline void run_http_and_ws(vix::App &app, vix::websocket::Server &ws, int port = 8080) |
139 | 140 | { |
140 | | - // Register docs once (global registry). No router needed. |
141 | 141 | register_ws_openapi_docs_once(); |
142 | | - |
| 142 | + auto r = app.router(); |
| 143 | + if (r) |
| 144 | + vix::openapi::register_openapi_and_docs(*r, "Vix API", "0.0.0"); |
143 | 145 | vix::websocket::AttachedRuntime runtime{app, ws}; |
144 | 146 |
|
145 | | - app.listen(port, [&](const vix::utils::ServerReadyInfo &base) |
| 147 | + app.listen(port, [&]() |
| 148 | + { |
| 149 | + if (!app.has_server_ready_info()) |
146 | 150 | { |
147 | | - vix::utils::ServerReadyInfo info = base; |
148 | | - info.show_ws = true; |
149 | | - info.ws_scheme = "ws"; |
150 | | - info.ws_host = "localhost"; |
151 | | - info.ws_port = ws.port(); |
152 | | - info.ws_path = "/"; |
153 | | - vix::utils::RuntimeBanner::emit_server_ready(info); }); |
| 151 | + console.warn("server ready info not available"); |
| 152 | + return; |
| 153 | + } |
| 154 | + |
| 155 | + auto info = app.server_ready_info(); |
| 156 | + info.show_ws = true; |
| 157 | + info.ws_scheme = "ws"; |
| 158 | + info.ws_host = "localhost"; |
| 159 | + info.ws_port = ws.port(); |
| 160 | + info.ws_path = "/"; |
| 161 | + |
| 162 | + vix::utils::RuntimeBanner::emit_server_ready(info); }); |
154 | 163 |
|
155 | 164 | app.wait(); |
156 | 165 | app.close(); |
|
0 commit comments