mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Removed redundant code for more performant processing
This commit is contained in:
parent
dcba72c891
commit
0e617dcfb6
2 changed files with 3 additions and 4 deletions
|
@ -9,7 +9,7 @@ class Kemal::Handler < HTTP::Handler
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(request)
|
def call(request)
|
||||||
response = exec_request(request)
|
response = process_request(request)
|
||||||
response || call_next(request)
|
response || call_next(request)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@ class Kemal::Handler < HTTP::Handler
|
||||||
@routes << Route.new(method, path, &handler)
|
@routes << Route.new(method, path, &handler)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exec_request(request)
|
def process_request(request)
|
||||||
components = request.path.not_nil!.split "/"
|
|
||||||
@routes.each do |route|
|
@routes.each do |route|
|
||||||
match = route.match?(request)
|
match = route.match?(request)
|
||||||
if match
|
if match
|
||||||
|
|
|
@ -10,8 +10,8 @@ class Kemal::Route
|
||||||
end
|
end
|
||||||
|
|
||||||
def match?(request)
|
def match?(request)
|
||||||
components = request.path.not_nil!.split "/"
|
|
||||||
return nil unless request.method == @method
|
return nil unless request.method == @method
|
||||||
|
components = request.path.not_nil!.split "/"
|
||||||
return nil unless components.size == @components.size
|
return nil unless components.size == @components.size
|
||||||
@components.zip(components) do |route_component, req_component|
|
@components.zip(components) do |route_component, req_component|
|
||||||
unless route_component.starts_with? ':'
|
unless route_component.starts_with? ':'
|
||||||
|
|
Loading…
Reference in a new issue