require 'sinatra' require 'sinatra/contrib' get '/' do < 404 EOHTML end get '/fail_4_times' do @@tries ||= 0 @@tries += 1 if @@tries <= 5 # Return a 0 error code. 0 else 'Stuff' end end get '/fail' do # Return a 0 error code. 0 end get '/include' do <Follow 1 Follow 2 Skip 1 EOHTML end get '/skip' do <Skip 1 Skip 2 Follow EOHTML end get '/skip-me/*' do <Skip 1 Skip 2 EOHTML end get '/follow-me' do 'You should see this.' end get '/sleep' do sleep 2 <Stuff EOHTML end get '/something' do 'Stuff' end get '/path_params' do <path_params path_params path_params path_params EOHTML end get '/foreign_domain' do <goto_foreign_domain EOHTML end get '/goto_foreign_domain' do redirect 'http://google.com/' end get '/relative_redirect' do headers 'Location' => '/stacked_redirect' 301 end get '/redirect' do redirect '/' end get '/skip_redirect' do redirect 'http://google.com' end get '/stacked_redirect' do redirect '/stacked_redirect1' end get '/stacked_redirect1' do redirect '/stacked_redirect2' end get '/stacked_redirect2' do redirect '/stacked_redirect3' end get '/stacked_redirect3' do redirect '/stacked_redirect4' end get '/stacked_redirect4' do end get '/redundant' do <Redundant 1 EOHTML end get '/redundant/1' do <Redundant 2 EOHTML end get '/redundant/2' do <Redundant 3 EOHTML end get '/redundant/3' do 'End of the line.' end get '/a_pushed_path' do end get '/some-path blah! %25&$' do < Weird EOHTML end get '/another weird path %25"&*[$)' do 'test' end get '/loop' do < Loop EOHTML end get '/loop_back' do < Loop EOHTML end get '/with_cookies' do cookies['my_cookie'] = 'my value' < This needs a cookie EOHTML end get '/with_cookies2' do if cookies['my_cookie'] == 'my value' <<-EOHTML This needs a cookie EOHTML end end get '/with_cookies3' do end get '/auto-redundant' do str = '' 10.times do str += <<-EOHTML Stuff EOHTML end 10.times do str += <<-EOHTML Stuff EOHTML end str end get '/lots_of_paths' do html = '' 50.times do |i| html << <<-EOHTML Stuff EOHTML end html end get '/lots_of_paths/:id' do |id| html = '' 100.times do |i| html << <<-EOHTML Stuff EOHTML end html end get '/lots_of_paths/:id/:id2' do |id, id2| html = '' 500.times do |i| html << <<-EOHTML Stuff EOHTML end html end get '/lots_of_paths/:id/:id2/:id3' do 'End of the line...' end