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

before_all handler is called after user defined handlers #698

Open
syeopite opened this issue Dec 18, 2024 · 0 comments
Open

before_all handler is called after user defined handlers #698

syeopite opened this issue Dec 18, 2024 · 0 comments

Comments

@syeopite
Copy link

Description

This may just be expected behavior but I was caught pretty off guard when I realized that the before_all handler is actually just called directly before the routes rather than being the first in the handler chain

require "kemal"

class CustomHandler < Kemal::Handler
  def call(context)
    puts "This is a custom handler"
    call_next context
  end
end

before_all { puts "Before all handler" }

add_handler CustomHandler.new

get "/" { puts "route!" }

Kemal.run

Results in the following on a request

This is a custom handler
Before all handler
route!

It lead to some problems when I was working on a program under the assumption that the custom user handlers would be called after the before_all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant