You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Commit ef69971 introduced caching of the Sinatra request object. Unfortunately this has the side effect of breaking routing when you have a setup consisting of sinatra middleware -> rack::builder -> sinatra application. For example, assume the following two classes:
class MyMiddleware < Sinatra::Base
end
class MyApp < Sinatra::Base
get "/foo" do
"hello"
end
end
If we have the following config.ru then a request to /test/foo works as expected:
builder = Rack::Builder.new do
map "/test" do
run MyApp
end
end
run builder
However, if we introduce the middleware, then a request to /test/foo generates a 404:
builder = Rack::Builder.new do
use MyMiddleware
map "/test" do
run MyApp
end
end
run builder
This is because MyMiddleware creates a cached copy of the Sinatra request in env['sinatra.request'] with the PATH_INFO set to /test/foo. Rack builder modifies the PATH_INFO and SCRIPT_NAME before MyApp runs, but MyApp uses the cached information from env['sinatra.request'].
The text was updated successfully, but these errors were encountered:
Commit ef69971 introduced caching of the Sinatra request object. Unfortunately this has the side effect of breaking routing when you have a setup consisting of sinatra middleware -> rack::builder -> sinatra application. For example, assume the following two classes:
If we have the following config.ru then a request to
/test/foo
works as expected:However, if we introduce the middleware, then a request to
/test/foo
generates a 404:This is because
MyMiddleware
creates a cached copy of the Sinatra request inenv['sinatra.request']
with thePATH_INFO
set to/test/foo
. Rack builder modifies thePATH_INFO
andSCRIPT_NAME
beforeMyApp
runs, butMyApp
uses the cached information fromenv['sinatra.request']
.The text was updated successfully, but these errors were encountered: