Skip to content

Commit 403ad19

Browse files
committed
Push kwargs onto middleware stack
1 parent f1d4fa1 commit 403ad19

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/hanami/api/middleware.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def initialize(prefix)
2323

2424
# @since 0.1.0
2525
# @api private
26-
def use(path, middleware, *args, &blk)
26+
def use(path, middleware, *args, **kwargs, &blk)
2727
# FIXME: test with prefix when Hanami::API.settings and prefix will be supported
2828
@stack[path] ||= []
29-
@stack[path].push([middleware, args, blk])
29+
@stack[path].push([middleware, args, kwargs, blk])
3030
end
3131

3232
# @since 0.1.1

spec/unit/hanami/api/middleware/stack_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
actual = subject.to_hash
1717
expected = {
18-
"/" => [["elapsed time", [], nil]],
19-
"/admin" => [["elapsed time", [], nil], ["admin auth", [], nil]],
20-
"/api" => [["elapsed time", [], nil], ["rate limiter", [4000], nil]],
21-
"/api/v1" => [["elapsed time", [], nil], ["rate limiter", [4000], nil], ["api v1 auth", ["secret-token"], nil], ["api v1 deprecation", [Date.today], nil]],
22-
"/api/v2" => [["elapsed time", [], nil], ["rate limiter", [4000], nil], ["api v2 auth", [], nil]],
23-
"/:locale" => [["elapsed time", [], nil], ["set locale", [], nil]],
24-
"/:locale/it" => [["elapsed time", [], nil], ["set locale", [], nil], ["analytics", [:it], nil]]
18+
"/" => [["elapsed time", [], {}, nil]],
19+
"/admin" => [["elapsed time", [], {}, nil], ["admin auth", [], {}, nil]],
20+
"/api" => [["elapsed time", [], {}, nil], ["rate limiter", [4000], {}, nil]],
21+
"/api/v1" => [["elapsed time", [], {}, nil], ["rate limiter", [4000], {}, nil], ["api v1 auth", ["secret-token"], {}, nil], ["api v1 deprecation", [Date.today], {}, nil]],
22+
"/api/v2" => [["elapsed time", [], {}, nil], ["rate limiter", [4000], {}, nil], ["api v2 auth", [], {}, nil]],
23+
"/:locale" => [["elapsed time", [], {}, nil], ["set locale", [], {}, nil]],
24+
"/:locale/it" => [["elapsed time", [], {}, nil], ["set locale", [], {}, nil], ["analytics", [:it], {}, nil]]
2525
}
2626

2727
expect(actual).to eq(expected)

0 commit comments

Comments
 (0)