Skip to content

Fix 2.7 deprecation warning in middleware/stack #2123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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 @@ -8,6 +8,7 @@

* Your contribution here.
* [#2115](https://github.com/ruby-grape/grape/pull/2115): Fix declared_params regression with multiple allowed types - [@stanhu](https://github.com/stanhu).
* [#2123](https://github.com/ruby-grape/grape/pull/2123): Fix 2.7 deprecation warning in middleware/stack - [@Legogris](https://github.com/Legogris).

### 1.5.0 (2020/10/05)

Expand Down
8 changes: 4 additions & 4 deletions lib/grape/middleware/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def [](i)
middlewares[i]
end

def insert(index, *args, &block)
def insert(index, *args, **kwargs, &block)
index = assert_index(index, :before)
middleware = self.class::Middleware.new(*args, &block)
middleware = self.class::Middleware.new(*args, **kwargs, &block)
middlewares.insert(index, middleware)
end

Expand All @@ -83,8 +83,8 @@ def insert_after(index, *args, &block)
insert(index + 1, *args, &block)
end

def use(*args, &block)
middleware = self.class::Middleware.new(*args, &block)
def use(*args, **kwargs, &block)
middleware = self.class::Middleware.new(*args, **kwargs, &block)
middlewares.push(middleware)
end

Expand Down