Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed executing filters when before and after is defined at the same time #612

Merged
merged 1 commit into from
Sep 1, 2021
Merged

fixed executing filters when before and after is defined at the same time #612

merged 1 commit into from
Sep 1, 2021

Conversation

mamantoha
Copy link
Contributor

Code to reproduce:

require "kemal"

before_all do |env|
  puts "BEFORE <"
end

after_all  do |env|
  puts "> AFTER"
end

get "/" do
  "Hello World!"
end

Kemal.run

after request will never be executed.

Not sure what going on here. But the origin of the issue is in radix shard. It does not properly handle paths without trailing /.

require "radix"

tree = Radix::Tree(Symbol).new

tree.add "after/ALL/*", :after
tree.add "before/ALL/*", :before

pp tree.find "after/ALL/*"
pp tree.find "before/ALL/*"

Output

#<Radix::Result(Symbol):0x7fbf3bb8bf00 @key=nil, @params={}, @payload=:after>
#<Radix::Result(Symbol):0x7fbf3bb8bcf0 @key=nil, @params={}, @payload=nil>

mamantoha added a commit to mamantoha/shards-info that referenced this pull request May 25, 2021
Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I would've never guessed this, thank you so much @mamantoha 🙏

@sdogruyol sdogruyol merged commit 14aabb8 into kemalcr:master Sep 1, 2021
@mamantoha mamantoha deleted the fix-before-after-filters branch October 25, 2022 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants