require 'sinatra' require 'sinatra/contrib' def default 'default' end def get_result( str ) if str.end_with?( '1=2' ) 'Could not find any results, bugger off!' elsif str.end_with?( '1=1' ) || str == default '1 item found: Blah blah blah...' else 'No idea what you want mate...' end end get '/' do <<-EOHTML Link Form Cookie Header EOHTML end get "/link" do <<-EOHTML Link EOHTML end get "/link/append" do return if !params['input'].start_with?( default ) get_result( params['input'] ) end get "/form" do <<-EOHTML
EOHTML end get "/form/append" do return if !params['input'] || !params['input'].start_with?( default ) get_result( params['input'] ) end get "/cookie" do <<-EOHTML Cookie EOHTML end get "/cookie/append" do cookies['cookie'] ||= default return if !cookies['cookie'].start_with?( default ) get_result( cookies['cookie'] ) end