Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
decouple server_routes and server_http
  • Loading branch information
ngxson committed Nov 29, 2025
commit c5f8cdf320536ca01cd56a183e69acbadba53e12
3 changes: 1 addition & 2 deletions tools/server/server-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3172,9 +3172,8 @@ void server_routes::init_routes() {

this->get_models = [this](const server_http_req &) {
auto res = std::make_unique<server_res_generator>(ctx_server);
bool is_model_ready = ctx_http.is_ready.load();
json model_meta = nullptr;
if (is_model_ready) {
if (is_ready()) {
model_meta = ctx_server.model_meta();
}
bool has_mtmd = ctx_server.mctx != nullptr;
Expand Down
6 changes: 3 additions & 3 deletions tools/server/server-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ struct server_context {
struct server_res_generator;

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

Expand Down Expand Up @@ -79,5 +79,5 @@ struct server_routes {

const common_params & params;
server_context_impl & ctx_server;
server_http_context & ctx_http; // for reading is_ready
std::function<bool()> is_ready;
};
2 changes: 1 addition & 1 deletion tools/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int main(int argc, char ** argv) {
//

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

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