views:

16

answers:

1

I wrote a rack middleware for my rails that that does something based on the if the REQUEST_URI equals specific string.

However what I quickly found out was in my development environment, which is using WEBrick, is the server puts in the full url for the REQUEST_URI. On my production environment, which is on Heroku, it behaves like expected.

So I'm not sure what the best solution to this is. Rails has a function called request_uri which handles this but since this is happening in my rack middleware I don't think I can access it. Another thing is this just seems to affect my development environment so any solution would be better if it didn't end up slowing down the production environment by any noticeable amount.

A: 

This is what I came up with based on the regular expression found in request_uri

      env["REQUEST_URI"] = $1 if %r{^\w+\://[^/]+(/.*|$)$} =~ env["REQUEST_URI"]
hadees