Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [#2918](https://github.com/ruby-grape/grape/pull/2918): Skip the dry-types round trip when a value already is the declared type - [@ericproulx](https://github.com/ericproulx).
* [#2917](https://github.com/ruby-grape/grape/pull/2917): Read path captures out of the router's union match instead of re-running the route's pattern - [@ericproulx](https://github.com/ericproulx).
* [#2921](https://github.com/ruby-grape/grape/pull/2921): Pin the router's request-time isolation regressions through requests instead of its instance variables - [@ericproulx](https://github.com/ericproulx).
* [#2923](https://github.com/ruby-grape/grape/pull/2923): Read the versioners' `vendor`, `strict`, `parameter` and `cascade` off instance variables instead of two delegators per request - [@ericproulx](https://github.com/ericproulx).
* Your contribution here.

### 4.0.0 (2026-09-07)
Expand Down
11 changes: 10 additions & 1 deletion lib/grape/middleware/versioner/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,20 @@ def self.inherited(klass)

attr_reader :available_media_types, :error_headers, :versions

# Read off ivars rather than delegated through +version_options+ into
# +config+: the versioners ask for +vendor+, +strict+ or +parameter+ on
# every request, and each read went two Forwardable frames and two Data
# readers deep for a value fixed when the middleware was built.
attr_reader :cascade, :parameter, :strict, :vendor

def_delegators :config, :mount_path, :prefix, :version_options
def_delegators :version_options, :cascade, :parameter, :strict, :vendor

def initialize(app, **options)
super
@cascade = version_options.cascade
@parameter = version_options.parameter
@strict = version_options.strict
@vendor = version_options.vendor
@versions = config.versions&.map(&:to_s) # making sure versions are strings to ease potential match
@error_headers = cascade ? CASCADE_PASS_HEADER : {}
@available_media_types = build_available_media_types
Expand Down
Loading