{"id":23089233,"url":"https://github.com/steventen/grape-vs-martini","last_synced_at":"2025-09-08T22:32:26.095Z","repository":{"id":13928265,"uuid":"16627797","full_name":"steventen/grape-vs-martini","owner":"steventen","description":"Compare Ruby's Grape to Golang's Martini for Web API Server","archived":false,"fork":false,"pushed_at":"2015-04-22T20:57:54.000Z","size":185,"stargazers_count":31,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T08:45:32.157Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steventen.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2014-02-07T21:19:07.000Z","updated_at":"2022-08-06T03:22:57.000Z","dependencies_parsed_at":"2022-08-28T18:32:00.380Z","dependency_job_id":null,"html_url":"https://github.com/steventen/grape-vs-martini","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/steventen/grape-vs-martini","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steventen%2Fgrape-vs-martini","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steventen%2Fgrape-vs-martini/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steventen%2Fgrape-vs-martini/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steventen%2Fgrape-vs-martini/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steventen","download_url":"https://codeload.github.com/steventen/grape-vs-martini/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steventen%2Fgrape-vs-martini/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231445,"owners_count":25245659,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-16T20:31:05.905Z","updated_at":"2025-09-08T22:32:25.786Z","avatar_url":"https://github.com/steventen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grape-vs-martini\n\nAPI server example to compare Ruby's [Grape](https://github.com/intridea/grape) Web Framwork to [Martini](https://github.com/codegangsta/martini) Web Framwork in Go\n\n[See blog post for details](http://stevenyue.com/2014/02/10/from-rubys-grape-to-martini-in-go-for-building-web-api-server/)\n\nRespond to the following routes:\n\n    GET /projects(.json)\n    GET /project/:id(.json)\n\nResponse format would be like:\n\n\t{\"status\": \"Success\", \"data\": [...]}\n\t{\"status\": \"Fail\", \"error_message\": \"Bad api key\"}\n\nAn example `curl` command would be like:\n\t\n\tcurl \"http://127.0.0.1:8080/projects?key=61c2339c1bc92bc48120b55513cd568b\"\n\nFor Grape, `rack app` uses port `9292`, `rails app` uses port `3000` as default.\n\nFor Martini, port `8080` is used.\n\n## How to run the server\n\n### Grape Example\n\nUnder `grape-example`, there are two folders, in which Grape API is mounted on *Rack* or *Rails*, using [puma](https://github.com/puma/puma)\n\n#### On Rack\n\n1. Modify database settings in `config.ru` \n\n2. Run `bundle`\n\n3. Run `bundle exec rackup -o 127.0.0.1`\n\n#### On Rails\n\n1. Modify database settings in `config/database.yml` \n\n2. Run `bundle`\n\n3. Run `rails s puma -b 127.0.0.1`\n\n### Martini Example\n\nUnder `martini-example` folder\n\n1. Modify database settings in `server.go` file, change variables in `sql.Open()`\n\n2. Run `go run server.go entry.go`\n\n## How to create sample data\n\nExample uses MySQL as default database.\n\nInside mysql, run:\n\n\tmysql\u003e create database grape_vs_martini_api;\n\nDump sample data into database:\n\n\tmysql -u root -p grape_vs_martini_api \u003c grape_vs_martini_api.sql\n\nSample data includes 10 companies, each with 50 projects, so there are 500 projects in total.\n\nSample companies' api keys:\n\n\t61c2339c1bc92bc48120b55513cd568b\n\tbb27bc6b7330aaac63ac809df83311b8\n\te35402fa00728faf372abaf71623b7f4\n\tbca4bf9d131ab311760c5b790c8568a5\n\t49886a1c018496abb9ba4bf592c08d36\n\t850eedd94a4d9a01962628faac7ace91\n\td036682c6ac91a41ac9eac064c02a43b\n\t77a767c39adc71fb241285309ff37ee5\n\t75e82d812630bf6d9371339f3e634801\n\tb5125eeabadcd5b3e55a76694d2b62b8\n\n## Benchmark\n\nA simple `ab` test is made, with command `ab -c 10 -n 1000 http://127.0.0.1:8080/projects?key=61c2339c1bc92bc48120b55513cd568b`\n\nTest environment: Macbook Air CPU 1.7GHz Core i5, 8GB DDR3, OSX 10.9.1\n\nruby -v 2.0.0p247, go version go1.2 darwin/amd64, rails 3.2.16\n\n### Grape\n\n#### On Rack\n\n\tConcurrency Level:      10\n\tTime taken for tests:   16.277 seconds\n\tComplete requests:      1000\n\tFailed requests:        0\n\tWrite errors:           0\n\tTotal transferred:      2303000 bytes\n\tHTML transferred:       2211000 bytes\n\tRequests per second:    61.44 [#/sec] (mean)\n\tTime per request:       162.769 [ms] (mean)\n\tTime per request:       16.277 [ms] (mean, across all concurrent requests)\n\tTransfer rate:          138.17 [Kbytes/sec] received\n\n\tConnection Times (ms)\n\t              min  mean[+/-sd] median   max\n\tConnect:        0    0   0.0      0       0\n\tProcessing:    23  162  33.9    172     289\n\tWaiting:       17  156  33.2    169     278\n\tTotal:         23  162  33.9    173     290\n\n#### On Rails\n\t\n\tConcurrency Level:      10\n\tTime taken for tests:   15.902 seconds\n\tComplete requests:      1000\n\tFailed requests:        0\n\tWrite errors:           0\n\tTotal transferred:      2492000 bytes\n\tHTML transferred:       2211000 bytes\n\tRequests per second:    62.88 [#/sec] (mean)\n\tTime per request:       159.024 [ms] (mean)\n\tTime per request:       15.902 [ms] (mean, across all concurrent requests)\n\tTransfer rate:          153.03 [Kbytes/sec] received\n\n\tConnection Times (ms)\n\t              min  mean[+/-sd] median   max\n\tConnect:        0    0   0.0      0       0\n\tProcessing:    15  158  23.5    170     186\n\tWaiting:       15  158  23.5    170     185\n\tTotal:         16  158  23.5    171     186\n\n\n### Martini\n\n\tConcurrency Level:      10\n\tTime taken for tests:   0.900 seconds\n\tComplete requests:      1000\n\tFailed requests:        0\n\tWrite errors:           0\n\tTotal transferred:      2314000 bytes\n\tHTML transferred:       2211000 bytes\n\tRequests per second:    1110.80 [#/sec] (mean)\n\tTime per request:       9.003 [ms] (mean)\n\tTime per request:       0.900 [ms] (mean, across all concurrent requests)\n\tTransfer rate:          2510.14 [Kbytes/sec] received\n\n\tConnection Times (ms)\n\t              min  mean[+/-sd] median   max\n\tConnect:        0    0   0.3      0       3\n\tProcessing:     3    9   2.9      8      22\n\tWaiting:        3    8   2.9      8      22\n\tTotal:          3    9   2.9      8      23\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteventen%2Fgrape-vs-martini","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteventen%2Fgrape-vs-martini","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteventen%2Fgrape-vs-martini/lists"}