I am writing a route that bundles the response of several routes together so I need to trigger other routes from within Sinatra. I found this code in the Sinatra README to do that:
status, headers, body = call env.merge("PATH_INFO" => '/bar')
It doesn't, however, send the query string. So I tried this:
status, headers, body = call env.merge(
"PATH_INFO" => '/bar',
"QUERY_STRING" => 'param=1'
)
That doesn't seem to work. How can I call another route and pass the query string such that the values in the string end up in the params hash of the called route.
We are using Sinatra 1.3.1 and Rack 1.3.5.
So the solution is to clear out the @original_params
variable. Clearly, even if it appears in the Sinatra README this is not supported. Time permitting I'd rework my routes so this isn't required, but there you are.
@original_params = nil
status, headers, body = call env.merge(
"PATH_INFO" => '/bar',
"QUERY_STRING" => 'param=1'
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With