{"id":13631754,"url":"https://github.com/ruby-grape/grape-on-rack","last_synced_at":"2025-05-16T07:07:22.551Z","repository":{"id":2343627,"uuid":"3306052","full_name":"ruby-grape/grape-on-rack","owner":"ruby-grape","description":"A demo Grape API mounted on RACK.","archived":false,"fork":false,"pushed_at":"2025-05-09T22:40:36.000Z","size":2366,"stargazers_count":275,"open_issues_count":1,"forks_count":75,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-09T23:28:07.801Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ruby-grape.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["dblock"]}},"created_at":"2012-01-30T15:35:39.000Z","updated_at":"2025-05-09T22:40:33.000Z","dependencies_parsed_at":"2024-08-01T22:40:10.854Z","dependency_job_id":"27577a22-13f2-4166-a503-794d123082d0","html_url":"https://github.com/ruby-grape/grape-on-rack","commit_stats":{"total_commits":109,"total_committers":12,"mean_commits":9.083333333333334,"dds":"0.23853211009174313","last_synced_commit":"fe4dd924f4f0de7a2b56edd048c38160e93a3102"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-grape%2Fgrape-on-rack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-grape%2Fgrape-on-rack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-grape%2Fgrape-on-rack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-grape%2Fgrape-on-rack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby-grape","download_url":"https://codeload.github.com/ruby-grape/grape-on-rack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485065,"owners_count":22078767,"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":[],"created_at":"2024-08-01T22:02:37.051Z","updated_at":"2025-05-16T07:07:18.289Z","avatar_url":"https://github.com/ruby-grape.png","language":"Ruby","funding_links":["https://github.com/sponsors/dblock"],"categories":["Ruby"],"sub_categories":[],"readme":"Grape API on Rack\n=================\n\n[![Test](https://github.com/ruby-grape/grape-on-rack/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ruby-grape/grape-on-rack/actions/workflows/test.yml)\n[![Code Climate](https://codeclimate.com/github/ruby-grape/grape-on-rack.svg)](https://codeclimate.com/github/ruby-grape/grape-on-rack)\n\nA [Grape](http://github.com/ruby-grape/grape) API mounted on Rack.\n\nRun\n---\n\n```\n$ bundle install\n$ rackup\n\nLoading NewRelic in developer mode ...\nPuma starting in single mode...\n* Puma version: 6.4.0 (ruby 2.7.7-p221) (\"The Eagle of Durango\")\n*  Min threads: 0\n*  Max threads: 5\n*  Environment: development\n*          PID: 82944\n* Listening on http://127.0.0.1:9292\n* Listening on http://[::1]:9292\n```\n\nList Routes\n-----------\n\n```\nrake routes\n```\n\nExplore the API\n---------------\n\nExplore the API using [Swagger UI](https://github.com/swagger-api/swagger-ui). Run the application and navigate to [http://locahost:9292/swagger/index.html](http://locahost:9292/swagger/index.html).\n\n\n## Examples\n### [ping](api/ping.rb)\n\nA hello world example that returns a JSON document.\n\n```\n$ curl http://localhost:9292/api/ping\n\n{\"ping\":\"pong\"}\n```\n\n### [post_put](api/post_put.rb)\n\nA simple `POST` and `PUT` example.\n\n```\ncurl -XPOST -d '' http://localhost:9292/api/ring \n\n{\"rang\":7}\n```\n\n```\ncurl -XPUT -d '{\"count\":2}' -H \"Content-Type:application/json\" http://localhost:9292/api/ring \n\n{\"rang\":9}\n```\n\n### [post_json](api/post_json.rb)\n\nAn example that shows a `POST` of JSON data.\n\n```\n$ curl -XPOST http://localhost:9292/api/spline -d '{\"reticulated\":\"lots\"}' -H \"Content-Type:application/json\"\n\n{\"reticulated\":\"lots\"}\n```\n\n### [get_json](api/get_json.rb)\n\nAn example that pre-processes params sent as JSON data.\n\n```\n$ curl http://localhost:9292/api/reticulated_splines?splines=[{\"id\":1,\"reticulated\":true},{\"id\":2,\"reticulated\":false}]\n\n[{\"id\":1,\"reticulated\":false},{\"id\":2,\"reticulated\":true}]\n```\n\n### [rescue_from](api/rescue_from.rb)\n\nAn example of `rescue_from` that wraps all exceptions in an HTTP error code 500.\n\n```\n$ curl -i http://localhost:9292/api/raise\nHTTP/1.1 500 Internal Server Error\nLast-Modified: Wed, 15 Jun 2022 01:12:37 GMT\nContent-Type: text/html\nContent-Length: 234\nVary: Origin\nServer: WEBrick/1.4.2 (Ruby/2.6.5/2019-10-01)\nDate: Sat, 18 Jun 2022 01:51:25 GMT\nConnection: Keep-Alive\n\n\u003chtml\u003e\n \u003chead\u003e\n  \u003ctitle\u003eUnexpected Error\u003c/title\u003e\n\u003c/head\u003e\n \u003cbody\u003e\n  \u003ch1\u003eOuch...\u003c/h1\u003e\n  \u003ca href=\"http://rack.rubyforge.org/\"\u003e\n   \u003cimg src=\"/images/rack-logo.png\"\u003e\n  \u003c/a\u003e\n  \u003cp\u003e\n    Something went terribly wrong.\n  \u003c/p\u003e\n \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### [path_versioning](api/path_versioning.rb)\n\nAn example that uses path-based versioning.\n\n```\n$ curl http://localhost:9292/api/vendor\n\n{\"path\":\"acme\"}\n```\n\n### [header_versioning](api/header_versioning.rb)\n\nAn example that uses vendor header-based versioning.\n\n```\n$ curl -H \"Accept:application/vnd.acme-v1+json\" http://localhost:9292/api\n\n{\"header\":\"acme\"}\n```\n### [wrap_response](api/wrap_response.rb)\n\nA middleware that wraps all responses and always returns HTTP code 200.\n\n```\n$ curl http://localhost:9292/api/decorated/ping\n\n{\"body\":{\"ping\":\"pong\"},\"status\":200}\n```\n\n### [content_type](api/content_type.rb)\n\nAn example that overrides the default `Content-Type` or returns data in both JSON and XML formats.\n\n```\n$ curl http://localhost:9292/api/plain_text\n\nA red brown fox jumped over the road.\n```\n\n```\n$ curl http://localhost:9292/api/mixed\n\n{\"data\":\"A red brown fox jumped over the road.\"}\n```\n\n```\n$ curl http://localhost:9292/api/mixed.xml\n\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003chash\u003e\n  \u003cdata\u003eA red brown fox jumped over the road.\u003c/data\u003e\n\u003c/hash\u003e\n```\n\n### [upload_file](api/upload_file.rb)\n\nAn example that demonstrates a file upload and download.\n\n```\n$ curl -X POST -i -F image_file=@spec/fixtures/grape_logo.png http://localhost:9292/api/avatar\n\n{\"filename\":\"grape_logo.png\",\"size\":4272}\n```\n\n```\n$ curl -X POST -i -F file=@spec/fixtures/grape_logo.png http://localhost:9292/api/download.png\n\nHTTP/1.1 201 Created\nContent-Type: image/png\nContent-Disposition: attachment; filename*=UTF-8''grape_logo.png\nVary: Origin\nContent-Length: 4272\nServer: WEBrick/1.4.2 (Ruby/2.6.5/2019-10-01)\nDate: Sat, 18 Jun 2022 02:12:21 GMT\nConnection: Keep-Alive\n```\n\n```\n$ curl -X POST -i -F file=@api/ping.rb http://localhost:9292/api/download.rb\n\nHTTP/1.1 201 Created\nContent-Type: application/x-ruby\nContent-Disposition: attachment; filename*=UTF-8''ping.rb\nVary: Origin\nContent-Length: 115\nServer: WEBrick/1.4.2 (Ruby/2.6.5/2019-10-01)\nDate: Sat, 18 Jun 2022 02:12:47 GMT\nConnection: Keep-Alive\n\nmodule Acme\n  class Ping \u003c Grape::API\n    format :json\n    get '/ping' do\n      { ping: 'pong' }\n    end\n  end\nend\n```\n\n### [entites](api/entities.rb)\n\nAn example of using [grape-entity](https://github.com/ruby-grape/grape-entity).\n\n```\n$ curl http://localhost:9292/api/entities/1\n\n{\"tool\":{\"id\":\"1\",\"length\":10,\"weight\":\"20kg\"}}\n```\n\n### [headers](api/headers.rb)\n\nDemonstrates header case-sensitive handling.\n\n```\n$ curl http://localhost:9292/api/headers/Host\n\n{\"Host\":\"localhost:9292\"}\n```\n\n### [stream_data](api/stream_data.rb)\n\nAn example of streaming data.\n\n```\ncurl http://localhost:9292/api/stream --no-buffer\n1\n2\n3\n...\n```\n\nNew Relic\n---------\n\nThe application is setup with NewRelic w/ Developer Mode. Navigate to http://localhost:9292/newrelic after making some API calls.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-grape%2Fgrape-on-rack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby-grape%2Fgrape-on-rack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-grape%2Fgrape-on-rack/lists"}