refactor(apigatewayv2): split resolve_action by endpoint shape#335
Merged
vieiralucas merged 1 commit intomainfrom Apr 13, 2026
Merged
refactor(apigatewayv2): split resolve_action by endpoint shape#335vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
resolve_action was a single 107-line match that enumerated 33
(Method, path-length, collection-name) combinations, each arm
performing a segs[N].clone() for api_id and sometimes another
segs[4].clone() for resource_id.
Collapse by resolving api_id / resource_id / collection once at
the top of the function, and then dispatching to two smaller
helpers:
- resolve_collection_action handles the 4-segment
/v2/apis/{id}/{collection} endpoints (POST creates, GET lists)
for routes, integrations, stages, deployments, and authorizers.
- resolve_resource_action handles the 5-segment
/v2/apis/{id}/{collection}/{resource-id} endpoints (GET, PATCH,
DELETE) for the same five collections.
resolve_action itself is now a 30-line outer match that only
decides which sub-helper to consult and wraps the result with the
shared api_id / resource_id it already computed. The total number
of segs clones drops from ~33 to 2 (the upfront Option<String>
bindings). No behavior change.
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
`resolve_action` was a single 107-line match that enumerated 33 (Method, path-length, collection-name) combinations, each arm performing a `segs[N].clone()` for `api_id` and sometimes another `segs[4].clone()` for `resource_id`.
Collapse by resolving `api_id` / `resource_id` / `collection` once at the top of the function, and then dispatching to two smaller helpers:
`resolve_action` itself is now a 30-line outer match that only decides which sub-helper to consult and wraps the result with the shared `api_id` / `resource_id` it already computed. The total number of `segs` clones drops from ~33 to 2 (the upfront `Option` bindings). No behavior change.
Test plan
Summary by cubic
Refactors API Gateway v2 action resolution by splitting
resolve_actioninto helpers based on endpoint shape. Reduces duplication and string clones; behavior is unchanged.api_id,resource_id, andcollectiononce at the top.resolve_collection_actionfor/v2/apis/{id}/{collection}(POST create, GET list).resolve_resource_actionfor/v2/apis/{id}/{collection}/{resource-id}(GET, PATCH, DELETE).clones from ~33 to 2 upfront bindings.Written for commit 750a872. Summary will update on new commits.