mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Make FilterBlock inner class of Kemal::FilterHandler
This commit is contained in:
parent
875737c446
commit
2fe27f0890
1 changed files with 10 additions and 10 deletions
|
@ -7,7 +7,7 @@ module Kemal
|
||||||
|
|
||||||
# This middleware is lazily instantiated and added to the handlers as soon as a call to `after_X` or `before_X` is made.
|
# This middleware is lazily instantiated and added to the handlers as soon as a call to `after_X` or `before_X` is made.
|
||||||
def initialize
|
def initialize
|
||||||
@tree = Radix::Tree(Array(Kemal::FilterBlock)).new
|
@tree = Radix::Tree(Array(FilterBlock)).new
|
||||||
Kemal.config.add_filter_handler(self)
|
Kemal.config.add_filter_handler(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,18 +69,18 @@ module Kemal
|
||||||
private def radix_path(verb, path, type : Symbol)
|
private def radix_path(verb, path, type : Symbol)
|
||||||
"#{type}/#{verb}/#{path}"
|
"#{type}/#{verb}/#{path}"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
class FilterBlock
|
class FilterBlock
|
||||||
property block : HTTP::Server::Context -> String
|
property block : HTTP::Server::Context -> String
|
||||||
|
|
||||||
def initialize(&block : HTTP::Server::Context -> _)
|
def initialize(&block : HTTP::Server::Context -> _)
|
||||||
@block = ->(context : HTTP::Server::Context) { block.call(context).to_s }
|
@block = ->(context : HTTP::Server::Context) { block.call(context).to_s }
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(context)
|
def call(context)
|
||||||
@block.call(context)
|
@block.call(context)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue