kemalcr / kemal

Fast, Effective, Simple Web Framework

Home Page:https://kemalcr.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filters being called regardless the path specified

kamk opened this issue · 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