title: Sinatra app that redirects POST/GET requests with parameters
body: <p>I'm migrating servers but unfortunately the old server IP is hardcoded inside my iPhone app. Obviously I'm going to submit an update that sets the API endpoint to my new server, but in the meantime I need to setup an app on the old server that redirects all the requests to the new server. I've heard Sinatra would be perfect for this.</p>
  
  <pre><code>require 'sinatra'
  
  get "/foo/bar" do
      redirect "http://new-server.com/foo/bar", 303
  end
  
  post "/foo/bar" do
      redirect "http://new-server.com/foo/bar", 303
  end
  </code></pre>
  
  <p>The problem is that these do not forward the GET or POST parameters along with the request. I read on the Sinatra doc that you can do that by putting them in the URL directly (works for GET requests), or by setting session variables.</p>
  
  <p>Is manually parsing and formatting the GET params to put them back into the redirect URL the only way to go for GET redirects? How are you supposed to forward POST parameters?</p>