Improve REST API routing and test architecture#15
Closed
cgwalters wants to merge 2 commits into
Closed
Conversation
It's really convenient and understandable for agents if they can run the `gh` CLI directly. We can enable this by setting proxy variables. Implement this for gitlab and forgejo as well. Assisted-by: OpenCode (Claude 3.5 Sonnet) Signed-off-by: Colin Walters <walters@verbum.org>
- Fix API routing to be service-specific instead of heuristic * get_service() now returns both service and service-specific prefix * Eliminates hard-coded API version stripping in favor of service-aware routing * Each service (GitHub /api/v3, GitLab /api/v4, etc.) handles its own prefix - Convert verbose REST API tests to table-driven patterns * Reduce code duplication in integration tests * Use data structures to define test cases * More maintainable and easier to extend Assisted-by: OpenCode (Sonnet 4.5)
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.
Summary
This PR addresses the issues identified in PR #14 by improving the REST API implementation:
🔧 Service-Specific API Routing
/api/v3,/api/v2etc., which was not service-specificget_service()method now returns both the service and its specific prefix, eliminating the need for generic prefix stripping📊 Table-Driven Tests
⚡ Async HTTP Improvements
Technical Details
The key changes:
src/services/mod.rs: Modifiedget_service()to return(service, prefix)tuple instead of just the servicesrc/servers/rest.rs: Updated to use service-specific prefix stripping instead of heuristic approachintegration-tests/src/tests/rest_api.rs: Converted verbose test functions to table-driven patternsThis makes the codebase more maintainable and fixes the "fishy" routing logic that was mentioned in the original issue.