Skip to content

Instantly share code, notes, and snippets.

@lambda2 lambda2/Readme.md Secret
Last active Sep 22, 2016

Embed
What would you like to do?
Webservice example implementation

Webservice basic implementation

gem install sinatra
ruby server.rb
require 'sinatra'
require "base64"
require "json"
# The secret key associated with your campus endpoint
SECRET = "laclesecrete"
#
# ================ Closes ================
#
post '/users/:login/close' do
key = params.delete(:key)
if key == SECRET
# TODO: Close the user
status 201
"Creating close for user #{params[:login]}"
end
end
post '/users/:login/unclose' do
key = params.delete(:key)
if key == SECRET
# TODO: Delete the close
status 204
"Deleting close for user #{params[:login]}"
end
end
#
# ================ Users ================
#
post '/users/new' do
key = params.delete(:key)
if key == SECRET
new_user = params
# TODO: Create the user
status 201
"Creating user #{params[:login]}"
end
end
post '/users/:login/update' do
key = params.delete(:key)
if key == SECRET
new_user = params
# TODO: Mettre a jour le user
status 204
"Updating user #{params[:login]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.