Class: BatchRequestApi::Middleware

Inherits:
Object
  • Object
show all
Includes:
BatchParallel, BatchSequential
Defined in:
lib/batch_request_api/middleware.rb

Instance Method Summary collapse

Methods included from BatchSequential

#batch_sequential

Methods included from BatchUtil

#build_response, #get_payload, #setup_env

Methods included from BatchParallel

#batch_parallel

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



10
11
12
# File 'lib/batch_request_api/middleware.rb', line 10

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/batch_request_api/middleware.rb', line 14

def call(env)
  if env['PATH_INFO'] == '/api/v1/batch_sequential'
    batch_sequential(env)
  elsif env['PATH_INFO'] == '/api/v1/batch_parallel'
    batch_parallel(env)
  else
    @app.call(env) # regular RAILS CRUD
  end
end