gem install sinatra
ruby server.rb
-
-
Save lambda2/2061ee935c6170f9e748 to your computer and use it in GitHub Desktop.
Webservice example implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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