Hello,
I've updated the world.db web service starter sample [1]
that gets you started building your own HTTP JSON API using the world.db
(incl. continents / countries / states / cities /etc.).
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 WorldDb::Models # e.g. Continent, Country, State, City, etc.
get '/countries(.:format)?' do
Country.by_key.all
end
get '/cities(.:format)?' do
City.by_key.all
end
get '/tag/:slug(.:format)?' do # e.g. /tag/north_america.csv
Tag.find_by!( slug: params['slug'] ).countries
end
...
end
Enjoy. Cheers.
[1]:
https://github.com/worlddb/world.db.starter
[2]:
https://github.com/rubylibs/webservice