Rack middleware in Rails to recode the URL