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 @@ -43,6 +43,7 @@
* [#2726](https://github.com/ruby-grape/grape/pull/2726): Reuse one `AttributesIterator` per validator and drop the unused `Enumerable` mixin - [@ericproulx](https://github.com/ericproulx).
* [#2728](https://github.com/ruby-grape/grape/pull/2728): Deprecate passing a positional options Hash to `auth`/`http_basic`/`http_digest`; pass keyword arguments instead - [@ericproulx](https://github.com/ericproulx).
* [#2733](https://github.com/ruby-grape/grape/pull/2733): Drop the dead `active_support/core_ext/hash/reverse_merge` require; call `ActiveSupport::HashWithIndifferentAccess.new(...)` directly at call sites - [@ericproulx](https://github.com/ericproulx).
* [#2738](https://github.com/ruby-grape/grape/pull/2738): Skip the redundant `env[Grape::Env::GRAPE_ROUTING_ARGS]` rewrite in `Router#process_route` when the matched route has no URL params to merge - [@ericproulx](https://github.com/ericproulx).
* Your contribution here.

#### Fixes
Expand Down
8 changes: 6 additions & 2 deletions lib/grape/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,13 @@ def halt?(response)
end

def process_route(route, input, env, include_allow_header: false)
args = env[Grape::Env::GRAPE_ROUTING_ARGS] || { route_info: route }
route_params = route.params(input)
env[Grape::Env::GRAPE_ROUTING_ARGS] = route_params.blank? ? args : args.merge(route_params)
if route_params.present?
args = env[Grape::Env::GRAPE_ROUTING_ARGS] || { route_info: route }
env[Grape::Env::GRAPE_ROUTING_ARGS] = args.merge(route_params)
else
env[Grape::Env::GRAPE_ROUTING_ARGS] ||= { route_info: route }
end
env[Grape::Env::GRAPE_ALLOWED_METHODS] = route.allow_header if include_allow_header
route.call(env)
end
Expand Down
Loading