For better example, please use batch_api
This gem allows multiple requests to be batch into a single request. This can be handy when doing API calls from mobile devices with a slow connection.
Add this line to your application's Gemfile:
gem 'rack-batch', require: "rack/batch"
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-batch
...
require "rack/batch"
In a Rack config.ru
file somewhere:
use Rack::Batch, {endpoint: '/secret_batch', limit: 10}
run MyRackApp
Now when a user POSTs /secret_batch
endpoint then can make a request with multiple requests (no more than 10). All requests are passed through the ops
param.
Please look at the examples/
folder for usage.
Rack::Batch
can take several options as a hash argument.
- endpoint
- limit
- encode_json
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request