Repository navigation
refactor(server): dispatch through an explicit handler table checked against the registry (#1344) - #1486
Merged
Conversation
…against the registry (#1344)
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 2 of #1344. The hand-written
match (method, route_path)inhandlers/mod.rsbecomes a data table,HANDLERS: &[(&str, &str, Handler)], plushandler_for(method, path). The 78 rows are the former arms, same handler functions, same section comments;route()now doeshandler_for(...)and calls the handler, with the same 404 fallback.The source-scanning test (
dispatch_match_routes_equal_the_registry_rows, which readmod.rsas text) is replaced byhandler_table_equals_the_registry, which comparesHANDLERSandapi_registry::ENDPOINTSas data and rejects duplicates. A second test pinshandler_forto 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 inapi_registry.rsnow points at the table and the test.No behaviour change:
docs/api-reference.mdanddocs/core-contract.jsonregenerate byte-identical, so uteke-cloud's route_parity gate is unaffected (uteke-cloud#117 conditions kept).Why
ENDPOINTSis 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 therequest_typestring 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 warningsandcargo fmtare clean.cargo run -p docgenleavesdocs/untouched.