Hi Tom,
I'm running into a situation where I have a root controller with a middleware.
If I map a sub controller in it and have the sub controller inherit the parent one, I end up with the controller running twice.
Assuming that I'm trying to use Rack::Session::Cookie:
# base.rb
class Base < Scorched::Controller
middleware << proc do
use Rack::Session::Cookie, secret: 'mysecretcookie'
end
map pattern: '/sub', conditions: { method: 'GET' }, target: Sub
# If set after the mapping, it won't work for some reason
# middleware << proc do
# use Rack::Session::Cookie, secret: 'mysecretcookie'
# end
end
# sub.rb
class Sub < ApiV1
get '/hello' do
'world'
end
end
If I try to curl /sub/hello, I will end up with two headers for the cookie (middleware is run twice).
I tried to move it after the mappings, but it didn't run at all.