{"id":21251824,"url":"https://github.com/rubycocos/webservice","last_synced_at":"2025-07-11T01:32:24.260Z","repository":{"id":30665719,"uuid":"34221468","full_name":"rubycocos/webservice","owner":"rubycocos","description":"webservice gem - yet another HTTP JSON API (web service) builder","archived":false,"fork":false,"pushed_at":"2022-04-05T07:42:12.000Z","size":48,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-31T13:57:01.622Z","etag":null,"topics":["gem","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubycocos.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-19T19:42:09.000Z","updated_at":"2020-10-15T15:49:22.000Z","dependencies_parsed_at":"2022-08-21T02:20:27.482Z","dependency_job_id":null,"html_url":"https://github.com/rubycocos/webservice","commit_stats":null,"previous_names":["rubylibs/webservice"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubycocos%2Fwebservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubycocos%2Fwebservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubycocos%2Fwebservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubycocos%2Fwebservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubycocos","download_url":"https://codeload.github.com/rubycocos/webservice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225669616,"owners_count":17505363,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gem","ruby"],"created_at":"2024-11-21T03:44:55.324Z","updated_at":"2024-11-21T03:44:55.943Z","avatar_url":"https://github.com/rubycocos.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webservice\n\nwebservice gem - yet another HTTP JSON API (web service) builder\n\n* home  :: [github.com/rubylibs/webservice](https://github.com/rubylibs/webservice)\n* bugs  :: [github.com/rubylibs/webservice/issues](https://github.com/rubylibs/webservice/issues)\n* gem   :: [rubygems.org/gems/webservice](https://rubygems.org/gems/webservice)\n* rdoc  :: [rubydoc.info/gems/webservice](http://rubydoc.info/gems/webservice)\n\n\n## Usage\n\n[Dynamic Example](#dynamic-example) •\n[Classic Example](#classic-example) •\n[Rackup Example](#rackup-example)\n\n\n### Dynamic Example\n\nYou can load services at-runtime from files using `Webservice.load_file`.\nExample:\n\n```ruby\n# service.rb\n\nget '/' do\n  'Hello, world!'\nend\n```\n\nand\n\n```ruby\n# server.rb\n\nrequire 'webservice'\n\nApp = Webservice.load_file( './service.rb' )\nApp.run!\n```\n\nand to run type\n\n```\n$ ruby ./server.rb\n```\n\n\n### Classic Example\n\n```ruby\n# server.rb\n\nrequire 'webservice'\n\nclass App \u003c Webservice::Base\n  get '/' do\n    'Hello, world!'\n  end\nend\n\nApp.run!\n```\nand to run type\n\n```\n$ ruby ./server.rb\n```\n\n\n### Rackup Example\n\nUse `config.ru` and `rackup`. Example:\n\n```ruby\n# config.ru\n\nrequire `webservice`\n\nclass App \u003c Webservice::Base\n  get '/' do\n    'Hello, world!'\n  end\nend\n\nrun App\n```\n\nand to run type\n\n```\n$ rackup      # will (auto-)load config.ru\n```\n\nNote: `config.ru` is a shortcut (inline)\nversion of `Rack::Builder.new do ... end`:\n\n```ruby\n# server.rb\n\nrequire 'webservice'\n\nclass App \u003c Webservice::Base\n  get '/' do\n    'Hello, world!'\n  end\nend\n\nbuilder = Rack::Builder.new do\n  run App\nend\n\nRack::Server.start builder.to_app\n```\n\nand to run type\n\n```\n$ ruby ./server.rb\n```\n\n\n\n## \"Real World\" Examples\n\nSee\n\n[**`beerkit / beer.db.service`**](https://github.com/beerkit/beer.db.service) -\nbeer.db HTTP JSON API (web service) scripts e.g.\n\n```ruby\nget '/beer/(r|rnd|rand|random)' do    # special keys for random beer\n  Beer.rnd\nend\n\nget '/beer/:key'\n  Beer.find_by! key: params['key']\nend\n\nget '/brewery/(r|rnd|rand|random)' do    # special keys for random brewery\n  Brewery.rnd\nend\n\nget '/brewery/:key'\n  Brewery.find_by! key: params['key']\nend\n\n...\n```\n\n\n[**`worlddb / world.db.service`**](https://github.com/worlddb/world.db.service) -\nworld.db HTTP JSON API (web service) scripts\n\n```ruby\nget '/countries(.:format)?' do\n  Country.by_key.all    # sort/order by key\nend\n\nget '/cities(.:format)?' do\n  City.by_key.all       # sort/order by key\nend\n\nget '/tag/:slug(.:format)?' do   # e.g. /tag/north_america.csv\n  Tag.find_by!( slug: params['slug'] ).countries\nend\n\n...\n```\n\n\n[**`sportdb / sport.db.service`**](https://github.com/sportdb/sport.db.service) -\nsport.db (football.db) HTTP JSON API (web service) scripts\n\n\n\n## License\n\nThe `webservice` scripts are dedicated to the public domain.\nUse it as you please with no restrictions whatsoever.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubycocos%2Fwebservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubycocos%2Fwebservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubycocos%2Fwebservice/lists"}