kemal icon indicating copy to clipboard operation
kemal copied to clipboard

Filters being called regardless the path specified

Open kamk opened this issue 1 year ago • 0 comments

Description

When (before|after)_all filter is specified for all paths (no argument) then any subsequent all filters are called ignoring path matching argument.

Steps to Reproduce

require "kemal"

before_all do |env|
  puts "Filter for all requests"
end

before_all "/xxx/*" do |env|
  puts "Filtering /xxx requests"
end

before_all "/yyy/*" do |env|
  puts "Filtering /yyy requests"
end

get "/*" do |env|
  puts "REQ: #{env.request.path}"
end

Kemal.run

Expected behavior:

Request GET /xxx/123 should output:

Filter for all requests
Filtering /xxx requests
REQ: /xxx/123

Actual behavior:

Request GET /xxx/123 outputs:

Filter for all requests
Filtering /xxx requests
Filtering /yyy requests
REQ: /xxx/123

Reproduces how often: ALWAYS

Versions

Crystal 1.11.2 (2024-01-18) LLVM: 17.0.6 Default target: aarch64-apple-darwin23.4.0

kemal version 1.5.0

kamk avatar Apr 15 '24 10:04 kamk