Module: BatchRequestApi::BatchUtil
- Included in:
- BatchParallel, BatchSequential
- Defined in:
- lib/batch_request_api/batch_util.rb
Instance Method Summary collapse
- #build_response(responses) ⇒ Object
- #get_payload(env) ⇒ Object
- #setup_env(env, item, json_body) ⇒ Object
Instance Method Details
#build_response(responses) ⇒ Object
9 10 11 |
# File 'lib/batch_request_api/batch_util.rb', line 9 def build_response(responses) [200, { 'Content-Type' => 'application/json' }, [{ responses: responses }.to_json]] end |
#get_payload(env) ⇒ Object
3 4 5 6 7 |
# File 'lib/batch_request_api/batch_util.rb', line 3 def get_payload(env) request = Rack::Request.new(env.deep_dup) payload = JSON.parse(request.body.read) payload['requests'] end |
#setup_env(env, item, json_body) ⇒ Object
13 14 15 16 17 |
# File 'lib/batch_request_api/batch_util.rb', line 13 def setup_env(env, item, json_body) env['PATH_INFO'] = item['url'] env['REQUEST_METHOD'] = item['method'] env['rack.input'] = StringIO.new(json_body) end |