mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Refactor global namespace DSL into OOP Kemal::Base
This commit is contained in:
parent
a5d8df7382
commit
aaa2109837
25 changed files with 420 additions and 387 deletions
|
@ -70,6 +70,7 @@ end
|
|||
describe "Handler" do
|
||||
it "adds custom handler before before_*" do
|
||||
filter_middleware = Kemal::FilterHandler.new
|
||||
Kemal.application.add_filter_handler filter_middleware
|
||||
filter_middleware._add_route_filter("GET", "/", :before) do |env|
|
||||
env.response << " is"
|
||||
end
|
||||
|
@ -77,6 +78,8 @@ describe "Handler" do
|
|||
filter_middleware._add_route_filter("GET", "/", :before) do |env|
|
||||
env.response << " so"
|
||||
end
|
||||
Kemal.application.add_filter_handler filter_middleware
|
||||
|
||||
add_handler CustomTestHandler.new
|
||||
|
||||
get "/" do
|
||||
|
@ -141,21 +144,21 @@ describe "Handler" do
|
|||
it "adds a handler at given position" do
|
||||
post_handler = PostOnlyHandler.new
|
||||
add_handler post_handler, 1
|
||||
Kemal.config.setup
|
||||
Kemal.config.handlers[1].should eq post_handler
|
||||
Kemal.application.setup
|
||||
Kemal.application.handlers[1].should eq post_handler
|
||||
end
|
||||
|
||||
it "assigns custom handlers" do
|
||||
post_only_handler = PostOnlyHandler.new
|
||||
post_exclude_handler = PostExcludeHandler.new
|
||||
Kemal.config.handlers = [post_only_handler, post_exclude_handler]
|
||||
Kemal.config.handlers.should eq [post_only_handler, post_exclude_handler]
|
||||
Kemal.application.handlers = [post_only_handler, post_exclude_handler]
|
||||
Kemal.application.handlers.should eq [post_only_handler, post_exclude_handler]
|
||||
end
|
||||
|
||||
it "is able to use %w in macros" do
|
||||
post_only_handler = PostOnlyHandlerPercentW.new
|
||||
exclude_handler = ExcludeHandlerPercentW.new
|
||||
Kemal.config.handlers = [post_only_handler, exclude_handler]
|
||||
Kemal.config.handlers.should eq [post_only_handler, exclude_handler]
|
||||
Kemal.application.handlers = [post_only_handler, exclude_handler]
|
||||
Kemal.application.handlers.should eq [post_only_handler, exclude_handler]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue