From 403ad1944aa365d55f12c12497704570801f2adb Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Mon, 8 Jul 2024 13:24:09 -0600 Subject: [PATCH] Push kwargs onto middleware stack --- lib/hanami/api/middleware.rb | 4 ++-- spec/unit/hanami/api/middleware/stack_spec.rb | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) 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)