class BatchRequestApi::Middleware

Constants

PATH_INFO_HEADER_KEY

Public Class Methods

new(app) click to toggle source
# File lib/batch_request_api/middleware.rb, line 12
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# 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) # regular RAILS CRUD
  end
end
is_batch_parallel_path?(path) click to toggle source
# 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) click to toggle source
# File lib/batch_request_api/middleware.rb, line 26
def is_batch_sequential_path?(path)
  BatchRequestApi.config.batch_sequential_paths.include?(path)
end