beer.db.starter Sample - Build Your Own HTTP JSON API (w/ beerd.db)

73 views
Skip to first unread message

Gerald Bauer

unread,
Aug 31, 2017, 4:28:01 AM8/31/17
to bee...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages