Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Created February 27, 2013 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blairanderson/5052053 to your computer and use it in GitHub Desktop.
Save blairanderson/5052053 to your computer and use it in GitHub Desktop.
registration
require 'rubygems'
require 'sinatra'
require 'json'
require 'sequel'
require 'pg'
require 'haml'
require 'shotgun'
get '/' do
haml :index
end
post '/sources' do
process_params(params)
end
def process_params(params)
@identifier = params[:identifier]
@rooturl = params[:rootUrl]
if missing_parameters?(params)
halt 400, "Bad Request! missing required parameters\n\n"
# elsif already_exists?(identifier: @identifier, rootUrl: @rooturl)
# out = halt 403, 'Identifier Already Exists!'
else
"#{{identifier: @id}.to_json}\n\n"
end
end
post '/sources/jumpstartlab/data' do
payload = JSON.parse(params[:payload])
payload2 = JSON.parse(payload)
"#{payload2}"
end
def missing_parameters?(params)
identifier = params[:identifier]
root = params[:rootUrl]
if identifier == nil || identifier == ""
true
elsif root == nil || root == ""
true
else
false
end
end
def already_exists?(params)
false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment