hanami / api

Minimal, lightweight, fastest Ruby framework for HTTP APIs.

Home Page:https://hanamirb.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rack middleware is not called when using scope with interpolation

ahx opened this issue · comments

Scenario

There seems to be a problem when adding a middleware inside a scope block with interpolation.
Here is an example:

scope 'i' do
  scope ':tenant_id' do
    use LogTenantIdMiddleware

    get 'foo' do
      "Hello, world #{params[:tenant_id]}"
     end
  end
end

Problem

GET "/i/42/foo"

  • LogTenantIdMiddleware is not called
  • Responds with status 200, "Hello, world 42"

GET "/i/:tenant_id/foo"

  • LogTenantIdMiddleware is called
  • Responds with status 200, "Hello, world :tenant_id"

Example

Here is a gist with a demo app to illustrate the issue.

founded fix in hanami-router, I will prepare PR and past link to PR here