Skip to content

Add mounted_app reader and app: keyword to Grape::Endpoint#2777

Open
ericproulx wants to merge 1 commit into
endpoint_path_kwargfrom
endpoint_app_kwarg
Open

Add mounted_app reader and app: keyword to Grape::Endpoint#2777
ericproulx wants to merge 1 commit into
endpoint_path_kwargfrom
endpoint_app_kwarg

Conversation

@ericproulx

Copy link
Copy Markdown
Contributor

Stacked on #2776#2775#2774 — review/merge those first. The base auto-retargets as the stack lands.

Summary

app (the Rack app or Grape API mounted at an endpoint) was only reachable by digging into the public options bag as endpoint.options[:app]. This is step 1 of moving it to a first-class accessor — additive and non-breaking.

Changes

  • Grape::Endpoint#initialize accepts app: as an explicit keyword (was pulled from **options).
  • New public Grape::Endpoint#mounted_app reader → config.app (the mounted app; nil for a plain block endpoint).
  • Grape's own mount-refresh dedup (refresh_already_mounted) now reads endpoint.mounted_app instead of endpoint.options[:app].
  • Added coverage for #mounted_app and for the refresh_already_mounted dedup path, which previously had none.

Non-breaking

endpoint.options[:app] is still populated exactly as before (same object; key absent for plain endpoints), so grape-swagger and any external readers keep working. No deprecation warning yet.

Why mounted_app, not app

@app already means the runnable Rack app (config.app || build_stack, invoked by call). A public app returning the raw config.app would be nil for ordinary block endpoints even though they're callable — confusing. mounted_app says exactly what it is.

Follow-ups (separate PRs)

  • Migrate grape-swagger to endpoint.mounted_app / endpoint.endpoints.
  • Drop :app from the options Hash in a major, with an UPGRADING note.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

`app` (the Rack app or Grape API mounted at an endpoint) was reachable
only by digging into the public options bag as `endpoint.options[:app]`.

Introduce a first-class `mounted_app` reader (returning `config.app`,
`nil` for a plain block endpoint) and accept `app:` as an explicit
keyword on `Grape::Endpoint#initialize`. Grape's own mount-refresh dedup
now reads `endpoint.mounted_app` instead of `options[:app]`.

This is additive and non-breaking: `options[:app]` is still populated
exactly as before for downstream consumers (e.g. grape-swagger), which
can migrate to `mounted_app` before it is eventually dropped from the
options Hash. Also adds the previously-missing coverage for the
`refresh_already_mounted` dedup path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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