Upload
pharo
View
89
Download
0
Tags:
Embed Size (px)
Citation preview
| books teapot | books := Dictionary new. teapot := Teapot configure: { #defaultOutput -> #json. #port -> 8080. #debugMode -> true }.
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.