Skip to content
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

use middleware prevents from migrating to ruby 3 #1720

Closed
EduardoSimon opened this issue Sep 7, 2021 · 3 comments
Closed

use middleware prevents from migrating to ruby 3 #1720

EduardoSimon opened this issue Sep 7, 2021 · 3 comments

Comments

@EduardoSimon
Copy link

EduardoSimon commented Sep 7, 2021

Context

Hi folks, I am trying to migrate a sinatra app from ruby 2.7 to ruby 3. My tests are failing when using a sinatra middleware like so when passing a keyword argument:

use MyMiddleware, keyword_argument: 'foo'

AFAIK there has been a breaking change regarding keyword arguments, now its mandatory to specify them in the method signature as such:

-- before
def foo(*args, &block)
  target(*args, &block)
end

-- after
def foo(*args, **kwargs, &block)
  target(*args, **kwargs, &block)
end

Possible solution

After reviewing the code it seems like the use method needs a simple signature change, but I don't know how this could impact the library. If the change is that simple and backwards-compatible, are you accepting PRs?

Thanks in advance.

@EduardoSimon EduardoSimon changed the title use middleware prevents to migrate to ruby 3 use middleware prevents from migratin to ruby 3 Sep 7, 2021
@EduardoSimon EduardoSimon changed the title use middleware prevents from migratin to ruby 3 use middleware prevents from migrating to ruby 3 Sep 7, 2021
@epergo
Copy link
Member

epergo commented Sep 7, 2021

That should work after #1701 but that change is still unreleased so could you try installing Sinatra from the master branch?

@epergo
Copy link
Member

epergo commented Sep 23, 2021

👋 @EduardoSimon did you try to use Sinatra from master? Did it work?

@olofheurgren
Copy link

That should work after #1701 but that change is still unreleased so could you try installing Sinatra from the master branch?

I had the same issue and can confirm that this solution works!

Tested with

use Rack::JSONBodyParser, verbs: ['POST', 'PATCH'], media: ['application/json', 'application/vnd.api+json']

where Rack::JSONBodyParser is from the rack-contrib gem.

@jkowens jkowens closed this as completed Oct 4, 2021
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

No branches or pull requests

4 participants