Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add rest-like api example

  • Loading branch information...
commit af949315bd60f71c7849f44976ec5b1f2179a6a4 1 parent 2587a0e
@stevenwilkin authored
Showing with 52 additions and 3 deletions.
  1. +0 −3  03_complex/01_complex.md
  2. +52 −0 03_complex/01_rest_like_api.md
View
3  03_complex/01_complex.md
@@ -1,3 +0,0 @@
-!SLIDE
-
-# Complex example
View
52 03_complex/01_rest_like_api.md
@@ -0,0 +1,52 @@
+!SLIDE
+
+# Less basic examples
+
+
+!SLIDE smaller
+
+# REST-like API
+
+ @@@ ruby
+ # 03_rest_like.rb
+ require 'sinatra'
+
+ get '/lentils' do
+ "get all the lentils"
+ end
+
+ post '/lentils' do
+ "create a lentil"
+ end
+
+ get '/lentils/:id' do
+ "get lentil: #{params[:id]}"
+ end
+
+ put "/lentils/:id" do
+ "update lentil: #{params[:id]}"
+ end
+
+ delete "/lentils/:id" do
+ "delete lentil: #{params[:id]}"
+ end
+
+
+!SLIDE small
+
+# cURL all the verbs
+
+ $ curl -X GET http://0.0.0.0:4567/lentils
+ get all the lentils
+
+ $ curl -X POST http://0.0.0.0:4567/lentils
+ create a lentil
+
+ $ curl -X GET http://0.0.0.0:4567/lentils/123
+ get lentil: 123
+
+ $ curl -X PUT http://0.0.0.0:4567/lentils/123
+ update lentil: 123
+
+ $ curl -X DELETE http://0.0.0.0:4567/lentils/123
+ delete lentil: 123
Please sign in to comment.
Something went wrong with that request. Please try again.