Skip to content

Instantly share code, notes, and snippets.

@vangberg
Created March 14, 2009 03:31
Show Gist options
  • Save vangberg/78910 to your computer and use it in GitHub Desktop.
Save vangberg/78910 to your computer and use it in GitHub Desktop.
require "sinatra"
post "/foo" do
redirect "/bar"
end
get "/bar" do
"Hello, World!"
end
require "rest_client"
RestClient.post "http://localhost:9393/foo", {}
# the server
~/c/s/rest> shotgun app.rb
== Shotgun starting Rack::Handler::Mongrel on 0.0.0.0:9393
127.0.0.1 - - [14/Mar/2009 04:31:09] "POST /foo HTTP/1.1" 302 - 0.0008
127.0.0.1 - - [14/Mar/2009 04:31:09] "POST /foo HTTP/1.1" 302 - 0.0010
127.0.0.1 - - [14/Mar/2009 04:31:09] "POST /bar HTTP/1.1" 404 413 0.0008
127.0.0.1 - - [14/Mar/2009 04:31:09] "POST /bar HTTP/1.1" 404 413 0.0010
# the client
~/c/s/rest> ruby -rubygems getit.rb
/Users/h/.gems/gems/rest-client-0.9.2/lib/restclient/request.rb:142:in `process_result': Resource not found (RestClient::ResourceNotFound)
from /Users/h/.gems/gems/rest-client-0.9.2/lib/restclient/request.rb:106:in `transmit'
from /opt/local/lib/ruby/1.8/net/http.rb:543:in `start'
from /Users/h/.gems/gems/rest-client-0.9.2/lib/restclient/request.rb:103:in `transmit'
from /Users/h/.gems/gems/rest-client-0.9.2/lib/restclient/request.rb:36:in `execute_inner'
from /Users/h/.gems/gems/rest-client-0.9.2/lib/restclient/request.rb:28:in `execute'
from /Users/h/.gems/gems/rest-client-0.9.2/lib/restclient/request.rb:31:in `execute'
from /Users/h/.gems/gems/rest-client-0.9.2/lib/restclient/request.rb:12:in `execute'
from /Users/h/.gems/gems/rest-client-0.9.2/lib/restclient.rb:61:in `post'
from getit.rb:3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment