diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abbde5b..c282640 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,7 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{matrix.ruby}} + bundler-cache: true # 'bundle install' and cache gems - name: Install latest bundler run: | gem install bundler --no-document diff --git a/lib/hanami/api/middleware.rb b/lib/hanami/api/middleware.rb index f35ebca..f141f61 100644 --- a/lib/hanami/api/middleware.rb +++ b/lib/hanami/api/middleware.rb @@ -23,10 +23,10 @@ def initialize(prefix) # @since 0.1.0 # @api private - def use(path, middleware, *args, &blk) + def use(path, middleware, *args, **kwargs, &blk) # FIXME: test with prefix when Hanami::API.settings and prefix will be supported @stack[path] ||= [] - @stack[path].push([middleware, args, blk]) + @stack[path].push([middleware, args, kwargs, blk]) end # @since 0.1.1 diff --git a/spec/unit/hanami/api/middleware/stack_spec.rb b/spec/unit/hanami/api/middleware/stack_spec.rb index a2a8479..b812a15 100644 --- a/spec/unit/hanami/api/middleware/stack_spec.rb +++ b/spec/unit/hanami/api/middleware/stack_spec.rb @@ -15,13 +15,13 @@ actual = subject.to_hash expected = { - "/" => [["elapsed time", [], nil]], - "/admin" => [["elapsed time", [], nil], ["admin auth", [], nil]], - "/api" => [["elapsed time", [], nil], ["rate limiter", [4000], nil]], - "/api/v1" => [["elapsed time", [], nil], ["rate limiter", [4000], nil], ["api v1 auth", ["secret-token"], nil], ["api v1 deprecation", [Date.today], nil]], - "/api/v2" => [["elapsed time", [], nil], ["rate limiter", [4000], nil], ["api v2 auth", [], nil]], - "/:locale" => [["elapsed time", [], nil], ["set locale", [], nil]], - "/:locale/it" => [["elapsed time", [], nil], ["set locale", [], nil], ["analytics", [:it], nil]] + "/" => [["elapsed time", [], {}, nil]], + "/admin" => [["elapsed time", [], {}, nil], ["admin auth", [], {}, nil]], + "/api" => [["elapsed time", [], {}, nil], ["rate limiter", [4000], {}, nil]], + "/api/v1" => [["elapsed time", [], {}, nil], ["rate limiter", [4000], {}, nil], ["api v1 auth", ["secret-token"], {}, nil], ["api v1 deprecation", [Date.today], {}, nil]], + "/api/v2" => [["elapsed time", [], {}, nil], ["rate limiter", [4000], {}, nil], ["api v2 auth", [], {}, nil]], + "/:locale" => [["elapsed time", [], {}, nil], ["set locale", [], {}, nil]], + "/:locale/it" => [["elapsed time", [], {}, nil], ["set locale", [], {}, nil], ["analytics", [:it], {}, nil]] } expect(actual).to eq(expected)