Make forward_match an internal kwarg instead of a route option#2774
Open
ericproulx wants to merge 1 commit into
Open
Make forward_match an internal kwarg instead of a route option#2774ericproulx wants to merge 1 commit into
ericproulx wants to merge 1 commit into
Conversation
`forward_match` was threaded from the mount/route DSL through `Endpoint::Options` and the route options hash, only to be read once in `Route#initialize` to pick the match function. Since the value it derives from (`config.app`) already lives on the endpoint, compute it locally in `to_routes` and pass it to `Grape::Router::Route.new` as a keyword argument. This drops `forward_match` from `Endpoint::Options`, from the route options hash, and removes the now-dead `BaseRoute#forward_match` delegator (which had no callers). Adds a direct unit test for `Route#match?` under both forward/non-forward modes and an UPGRADING note for the removed introspection surface. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9a58ae8 to
4b08638
Compare
Danger ReportNo issues found. |
This was referenced Jul 4, 2026
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
forward_matchwas a derived flag threaded from themount/routeDSL throughEndpoint::Optionsand the route options hash, only to be read once inRoute#initializeto select the match function (prefix match for mounted Rack apps, compiled pattern otherwise).Since the value it derives from (
config.app) already lives on the endpoint, this computes it locally inEndpoint#to_routesand passes it toGrape::Router::Route.newas a keyword argument, removing the round-trip.Changes
Grape::Router::Route#initializenow takesforward_match:as a keyword argument rather than readingoptions[:forward_match].Endpoint#to_routesderivesforward_matchlocally:config.app && !config.app.respond_to?(:inheritable_setting)— exactly the condition that previously lived in themountDSL.forward_matchfromEndpoint::Optionsand fromprepare_default_route_attributes(no longer carried in the route options hash).BaseRoute#forward_matchdelegator (no callers in the codebase).spec/grape/router/route_spec.rbcoveringRoute#match?under both forward and non-forward modes, plus a mount-contrast integration test.Upgrading
forward_matchis now internal: it is no longer readable viaroute.options[:forward_match]orroute.forward_match. Nothing in Grape consumed either path; documented inUPGRADING.md.🤖 Generated with Claude Code