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

Function dispatch_request

src/ui/http_server.c:1812–1934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1810}
1811
1812static void dispatch_request(cbm_http_server_t *srv, cbm_http_conn_t *c,
1813 const cbm_http_req_t *req) {
1814 if (!request_passes_http_security(srv, c, req))
1815 return;
1816
1817 bool is_get = strcmp(req->method, "GET") == 0;
1818 bool is_post = strcmp(req->method, "POST") == 0;
1819 bool is_delete = strcmp(req->method, "DELETE") == 0;
1820
1821 /* OPTIONS preflight for CORS */
1822 if (strcmp(req->method, "OPTIONS") == 0) {
1823 cbm_http_replyf(c, 204, g_cors, "%s", "");
1824 return;
1825 }
1826
1827 /* Private-generation proof used only by `daemon start --open`. The
1828 * challenge is public; the HMAC key exists only in this daemon's
1829 * authenticated application and HTTP server instances. */
1830 if (is_get && strcmp(req->path, "/__cbm/ui-readiness") == 0) {
1831 handle_ui_readiness(srv, c, req);
1832 return;
1833 }
1834
1835 /* POST /rpc → JSON-RPC dispatch (reuses existing MCP tools) */
1836 if (is_post && cbm_http_path_match(req->path, "/rpc")) {
1837 handle_rpc(c, req, srv->mcp);
1838 return;
1839 }
1840
1841 /* GET /api/layout → 3D graph layout */
1842 if (is_get && cbm_http_path_match(req->path, "/api/layout*")) {
1843 handle_layout(c, req);
1844 return;
1845 }
1846
1847 /* GET /api/repo-info → git remote / branch for GitHub deep-links */
1848 if (is_get && cbm_http_path_match(req->path, "/api/repo-info*")) {
1849 handle_repo_info(c, req);
1850 return;
1851 }
1852
1853 /* POST /api/index → start background indexing */
1854 if (is_post && cbm_http_path_match(req->path, "/api/index")) {
1855 handle_index_start(srv, c, req);
1856 return;
1857 }
1858
1859 /* GET /api/index-status → check indexing progress */
1860 if (is_get && cbm_http_path_match(req->path, "/api/index-status")) {
1861 handle_index_status(srv, c);
1862 return;
1863 }
1864
1865 /* GET /api/ui-config → language and local UI preferences */
1866 if (is_get && cbm_http_path_match(req->path, "/api/ui-config")) {
1867 handle_ui_config(c, req);
1868 return;
1869 }

Callers 1

cbm_http_server_runFunction · 0.85

Calls 15

cbm_http_replyfFunction · 0.85
handle_ui_readinessFunction · 0.85
cbm_http_path_matchFunction · 0.85
handle_rpcFunction · 0.85
handle_layoutFunction · 0.85
handle_repo_infoFunction · 0.85
handle_index_startFunction · 0.85
handle_ui_configFunction · 0.85
handle_browseFunction · 0.85
handle_adr_getFunction · 0.85
handle_adr_saveFunction · 0.85

Tested by

no test coverage detected