Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Simple Rest
Server
S. Ducasse
http://www.pharo.org
| books teapot |
books := Dictionary new.
teapot := Teapot configure:
	 	 	 	 	 { #defaultOutput -> #json.
	 	 	 	 	 #port ...
teapot
	 GET: '/books' -> books;
!
	 PUT: '/books/<id>' ->
	 	 	 [ :request | | book |
	 	 	 book := {'author' -> (request...
ZnClient new
url: 'http://localhost:8080/books/1';
formAt: 'author' put: 'SquareBracketAssociates';
formAt: 'title' put: ‘...
Upcoming SlideShare
Loading in …5
×

of

Pharo Hands-On: 04 teapot server Slide 1 Pharo Hands-On: 04 teapot server Slide 2 Pharo Hands-On: 04 teapot server Slide 3 Pharo Hands-On: 04 teapot server Slide 4
Upcoming SlideShare
Pharo Hand-Ons: 06 finding information
Next
Download to read offline and view in fullscreen.

0 Likes

Share

Download to read offline

Pharo Hands-On: 04 teapot server

Download to read offline

Part of one day hands-on on Pharo

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Pharo Hands-On: 04 teapot server

  1. 1. Simple Rest Server S. Ducasse http://www.pharo.org
  2. 2. | books teapot | books := Dictionary new. teapot := Teapot configure: { #defaultOutput -> #json. #port -> 8080. #debugMode -> true }.
  3. 3. teapot GET: '/books' -> books; ! PUT: '/books/<id>' -> [ :request | | book | book := {'author' -> (request at: #author). 'title' -> (request at: #title)} asDictionary. books at: (request at: #id) put: book ]; ! DELETE: '/books/<id>' -> [:request | books removeKey: (request at: #id)]; ! exception: KeyNotFound -> (TeaResponse notFound body: 'No such book'); ! start.
  4. 4. ZnClient new url: 'http://localhost:8080/books/1'; formAt: 'author' put: 'SquareBracketAssociates'; formAt: 'title' put: ‘Enterprise Pharo'; put

Part of one day hands-on on Pharo

Views

Total views

1,061

On Slideshare

0

From embeds

0

Number of embeds

7

Actions

Downloads

4

Shares

0

Comments

0

Likes

0

×