Hello,
I've updated the beer.db web service starter sample [1]
that gets you started building your own HTTP JSON API using the beer.db
(and friends).
What's news? The starter sample now uses the new webservice library [2]
(a simplified sinatra 2.0-style library for HTTP JSON APIs). Example:
class StarterApp < Webservice::Base
include BeerDb::Models # e.g. Beer, Brewery, Brand, etc.
# try special (reserved) keys for random beer first
get '/beer/(r|rnd|rand|random)' do
Beer.rnd
end
get '/beer/:key' do
Beer.find_by! key: params[ 'key' ]
end
...
end
Enjoy. Cheers. Prost.
[1]:
https://github.com/beerkit/beer.db.starter
[2]:
https://github.com/rubylibs/webservice