Skip to content

Instantly share code, notes, and snippets.

@vanpelt
Created June 3, 2010 00:59
Show Gist options
  • Save vanpelt/423263 to your computer and use it in GitHub Desktop.
Save vanpelt/423263 to your computer and use it in GitHub Desktop.
class FakeApp < Sinatra::Base
set :raise_errors, false
set :show_exceptions, false
set :dump_errors, false
#set :logging, true
post '/start' do
secret_key = "your secret"
payload = JSON.parse(params[:payload])
if(Digest::SHA1.hexdigest(params[:payload]+secret_key) == params[:signature])
"123ABCD"
else
401
end
end
post "/finish" do
secret_key = "your secret"
payload = JSON.parse(params[:payload])
if(Digest::SHA1.hexdigest(params[:payload]+secret_key) == params[:signature])
"OK"
else
401
end
end
error(401) do
"Couldn't do it, secret key didn't work"
end
not_found do
"Nothing here..."
end
error do
"Bummer Man! #{env['sinatra.error'].message}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment