Skip to content

Drop Grape::Middleware::Globals#2714

Merged
ericproulx merged 2 commits into
masterfrom
chore/drop-middleware-globals
May 14, 2026
Merged

Drop Grape::Middleware::Globals#2714
ericproulx merged 2 commits into
masterfrom
chore/drop-middleware-globals

Conversation

@ericproulx
Copy link
Copy Markdown
Contributor

@ericproulx ericproulx commented May 14, 2026

Summary

Grape::Middleware::Globals and the three env constants it sets (Grape::Env::GRAPE_REQUEST, Grape::Env::GRAPE_REQUEST_HEADERS, Grape::Env::GRAPE_REQUEST_PARAMS) have been dead code for years. Removing the class, its spec, and the constants.

Why

  • Never mounted in lib/. No use Grape::Middleware::Globals anywhere in production code. Grape::Endpoint#build_stack does not include it.
  • No internal consumers of its env keys. Nothing in lib/ reads env['grape.request'], env['grape.request.headers'], or env['grape.request.params']. Grape::Endpoint builds its Grape::Request directly (endpoint.rb:151), bypassing the middleware entirely.
  • No documentation references. README and UPGRADING never mention the class.
  • Origin is incidental. Introduced 2013 in commit 9987090b ("Add required option for oauth2 middleware") — bundled into an unrelated oauth2 change.

Breaking change

Anyone who mounted Grape::Middleware::Globals in their own custom Rack stack (to populate env['grape.request'] for downstream middleware) will lose it. UPGRADING includes a self-contained replacement snippet they can drop into their app.

The original implementation is preserved in git history at 6b4111b3:lib/grape/middleware/globals.rb.

Test plan

  • bundle exec rspec — 2288 examples, 0 failures (5 fewer than before; those were the deleted globals_spec.rb)
  • CI green across Gemfile variants

🤖 Generated with Claude Code

@ericproulx ericproulx force-pushed the chore/drop-middleware-globals branch from c205733 to 268e2c4 Compare May 14, 2026 12:19
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Danger Report

No issues found.

View run

@ericproulx ericproulx requested a review from dblock May 14, 2026 12:50
Comment thread UPGRADING.md Outdated
@ericproulx ericproulx force-pushed the chore/drop-middleware-globals branch from 268e2c4 to 98de963 Compare May 14, 2026 16:54
Grape::Middleware::Globals and its three env keys
(Grape::Env::GRAPE_REQUEST, GRAPE_REQUEST_HEADERS, GRAPE_REQUEST_PARAMS)
have been dead code for years. The middleware was introduced in 2013
(commit 9987090, bundled awkwardly into an oauth2 change) and was never
mounted by Grape's own stack — Endpoint builds its Grape::Request
directly. Nothing in lib/ reads grape.request* either; the env keys had
no internal consumers.

Outside lib/ the only reference was the file's own spec. README and
UPGRADING never mentioned the class.

Removing the class, the spec, and the three constants. The original
implementation is preserved in git history at
https://github.com/ruby-grape/grape/blob/6b4111b3/lib/grape/middleware/globals.rb.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ericproulx ericproulx force-pushed the chore/drop-middleware-globals branch from 98de963 to 0ee6584 Compare May 14, 2026 16:58
@ericproulx ericproulx merged commit bd0d51e into master May 14, 2026
79 checks passed
@ericproulx ericproulx deleted the chore/drop-middleware-globals branch May 14, 2026 17:03
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.

2 participants