Skip to content

Commit 5f7b502

Browse files
committed
decouple server_routes and server_http
1 parent 2141a3e commit 5f7b502

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tools/server/server-context.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ struct server_context {
4141
struct server_res_generator;
4242

4343
struct server_routes {
44-
server_routes(const common_params & params, server_context & ctx_server, server_http_context & ctx_http)
45-
: params(params), ctx_server(*ctx_server.impl), ctx_http(ctx_http) {
44+
server_routes(const common_params & params, server_context & ctx_server, std::function<bool()> is_ready = []() { return true; })
45+
: params(params), ctx_server(*ctx_server.impl), is_ready(is_ready) {
4646
init_routes();
4747
}
4848

@@ -79,5 +79,5 @@ struct server_routes {
7979

8080
const common_params & params;
8181
server_context_impl & ctx_server;
82-
server_http_context & ctx_http; // for reading is_ready
82+
std::function<bool()> is_ready;
8383
};

tools/server/server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int main(int argc, char ** argv) {
9999
//
100100

101101
// register API routes
102-
server_routes routes(params, ctx_server, ctx_http);
102+
server_routes routes(params, ctx_server, [&ctx_http]() { return ctx_http.is_ready.load(); });
103103

104104
ctx_http.get ("/health", ex_wrapper(routes.get_health)); // public endpoint (no API key check)
105105
ctx_http.get ("/v1/health", ex_wrapper(routes.get_health)); // public endpoint (no API key check)

0 commit comments

Comments
 (0)