MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / handle_ui_config

Function handle_ui_config

src/ui/http_server.c:102–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102static void handle_ui_config(cbm_http_conn_t *c, const cbm_http_req_t *req) {
103 const char *lang = NULL;
104 char cache_dir[1024];
105 snprintf(cache_dir, sizeof(cache_dir), "%s", cbm_resolve_cache_dir());
106 cbm_config_t *cfg = cbm_config_open(cache_dir);
107 if (cfg) {
108 const char *pinned = cbm_config_get(cfg, CBM_CONFIG_UI_LANG, "auto");
109 if (strcmp(pinned, "zh") == 0 || strcmp(pinned, "en") == 0) {
110 lang = pinned;
111 }
112 }
113
114 char lang_buf[8];
115 snprintf(lang_buf, sizeof(lang_buf), "%s", lang ? lang : detect_ui_lang(req->accept_language));
116 if (cfg) {
117 cbm_config_close(cfg);
118 }
119 cbm_http_replyf(c, 200, g_cors_json, "{\"lang\":\"%s\"}", lang_buf);
120}
121
122/* ── Server state ─────────────────────────────────────────────── */
123

Callers 1

dispatch_requestFunction · 0.85

Calls 6

cbm_resolve_cache_dirFunction · 0.85
cbm_config_openFunction · 0.85
cbm_config_getFunction · 0.85
detect_ui_langFunction · 0.85
cbm_config_closeFunction · 0.85
cbm_http_replyfFunction · 0.85

Tested by

no test coverage detected