Skip to content

refactor(server): dispatch through an explicit handler table checked against the registry (#1344) - #1486

Merged
ajianaz merged 1 commit into
developfrom
refactor/server-handler-table
Oct 16, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/server-handler-table

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

What

Part 2 of #1344. The hand-written match (method, route_path) in handlers/mod.rs becomes a data table, HANDLERS: &[(&str, &str, Handler)], plus handler_for(method, path). The 78 rows are the former arms, same handler functions, same section comments; route() now does handler_for(...) and calls the handler, with the same 404 fallback.

The source-scanning test (dispatch_match_routes_equal_the_registry_rows, which read mod.rs as text) is replaced by handler_table_equals_the_registry, which compares HANDLERS and api_registry::ENDPOINTS as data and rejects duplicates. A second test pins handler_for to the exact method and path. every_registry_row_has_a_handler (renamed from ..._arm) still proves every row reaches a handler at run time. The "keep in sync with the dispatch match" note in api_registry.rs now points at the table and the test.

No behaviour change: docs/api-reference.md and docs/core-contract.json regenerate byte-identical, so uteke-cloud's route_parity gate is unaffected (uteke-cloud#117 conditions kept).

Why

ENDPOINTS is compiled into both the lib (docgen) and the bin, so it cannot hold the handler function; the table lives bin-side and a test keeps the two row sets identical. That removes the last place where a route list was verified by grepping source text. Typed requests per operation and the request_type string stay open for #1439 phase 2.

Testing

  • cargo test -p uteke-server: 37, 126, 3 and 7 tests pass; full workspace passes on a clean run (one earlier run showed a single failure that did not reproduce in two further runs; no test was changed besides the dispatch tests).
  • cargo clippy --workspace --all-targets -D warnings and cargo fmt are clean.
  • cargo run -p docgen leaves docs/ untouched.
  • Most of the diff is the arms moving into table rows.

@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 88cd115 into develop Oct 16, 2026
15 checks passed
@ajianaz
ajianaz deleted the refactor/server-handler-table branch October 16, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant