Class: BatchRequestApi::Middleware
Constant Summary
collapse
'PATH_INFO'.freeze
Instance Method Summary
collapse
#batch_sequential
Methods included from BatchUtil
#build_response, #get_payload, #setup_env
#batch_parallel
Constructor Details
Returns a new instance of Middleware.
12
13
14
|
# File 'lib/batch_request_api/middleware.rb', line 12
def initialize(app)
@app = app
end
|
Instance Method Details
#call(env) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/batch_request_api/middleware.rb', line 16
def call(env)
if is_batch_sequential_path?(env[PATH_INFO_HEADER_KEY])
batch_sequential(env)
elsif is_batch_parallel_path?(env[PATH_INFO_HEADER_KEY])
batch_parallel(env)
else
@app.call(env) end
end
|
#is_batch_parallel_path?(path) ⇒ Boolean
30
31
32
|
# File 'lib/batch_request_api/middleware.rb', line 30
def is_batch_parallel_path?(path)
BatchRequestApi.config.batch_parallel_paths.include?(path)
end
|
#is_batch_sequential_path?(path) ⇒ Boolean
26
27
28
|
# File 'lib/batch_request_api/middleware.rb', line 26
def is_batch_sequential_path?(path)
BatchRequestApi.config.batch_sequential_paths.include?(path)
end
|