batch_request_api 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/routes.rb +6 -5
- data/lib/batch_request_api/configuration.rb +21 -0
- data/lib/batch_request_api/middleware.rb +13 -3
- data/lib/batch_request_api/version.rb +1 -1
- data/lib/batch_request_api.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95f9990c2d768e9e8d142ab3f354ffb62a489a55
|
4
|
+
data.tar.gz: c24eeedcbf58673347a7afffb71bd26c63d5c5d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9da5cf0eb497b10155c06bcde3e6c3845a328363d154a330453cf412a8338df06f2595f3b7c6dc78867b707f0db9073614a79733481f3063e002a9048dc2cdda
|
7
|
+
data.tar.gz: 4eb5725cb6cf3d29185e96ddf1cbdaeab12b6ac02e521778aa7ee57098800804ee1e91c66d28a5c53425581f78bf8c7f519d30018837024a8f1ce3dfd7153020
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
BatchRequestApi.config.batch_sequential_paths.each do |batch_sequential_path|
|
3
|
+
post batch_sequential_path, constraints: { format: :json }
|
4
|
+
end
|
5
|
+
|
6
|
+
BatchRequestApi.config.batch_parallel_paths.each do |batch_parallel_path|
|
7
|
+
post batch_parallel_path, constraints: { format: :json }
|
7
8
|
end
|
8
9
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BatchRequestApi
|
2
|
+
class << self
|
3
|
+
def config
|
4
|
+
@config ||= Configuration.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def configure
|
8
|
+
yield(config)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :batch_sequential_paths
|
14
|
+
attr_accessor :batch_parallel_paths
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
self.batch_sequential_paths = ['/api/v1/batch_sequential']
|
18
|
+
self.batch_parallel_paths = ['/api/v1/batch_parallel']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,24 +1,34 @@
|
|
1
1
|
require 'batch_request_api/batch_parallel'
|
2
2
|
require 'batch_request_api/batch_sequential'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
module BatchRequestApi
|
5
6
|
class Middleware
|
6
7
|
include BatchParallel
|
7
8
|
include BatchSequential
|
8
|
-
|
9
|
+
|
10
|
+
PATH_INFO_HEADER_KEY = 'PATH_INFO'.freeze
|
9
11
|
|
10
12
|
def initialize(app)
|
11
13
|
@app = app
|
12
14
|
end
|
13
15
|
|
14
16
|
def call(env)
|
15
|
-
if env[
|
17
|
+
if is_batch_sequential_path?(env[PATH_INFO_HEADER_KEY])
|
16
18
|
batch_sequential(env)
|
17
|
-
elsif env[
|
19
|
+
elsif is_batch_parallel_path?(env[PATH_INFO_HEADER_KEY])
|
18
20
|
batch_parallel(env)
|
19
21
|
else
|
20
22
|
@app.call(env) # regular RAILS CRUD
|
21
23
|
end
|
22
24
|
end
|
25
|
+
|
26
|
+
def is_batch_sequential_path?(path)
|
27
|
+
BatchRequestApi.config.batch_sequential_paths.include?(path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_batch_parallel_path?(path)
|
31
|
+
BatchRequestApi.config.batch_parallel_paths.include?(path)
|
32
|
+
end
|
23
33
|
end
|
24
34
|
end
|
data/lib/batch_request_api.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batch_request_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Srinivas Raghunathan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/batch_request_api/batch_parallel.rb
|
67
67
|
- lib/batch_request_api/batch_sequential.rb
|
68
68
|
- lib/batch_request_api/batch_util.rb
|
69
|
+
- lib/batch_request_api/configuration.rb
|
69
70
|
- lib/batch_request_api/engine.rb
|
70
71
|
- lib/batch_request_api/middleware.rb
|
71
72
|
- lib/batch_request_api/railtie.rb
|
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
93
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.6
|
94
|
+
rubygems_version: 2.4.6
|
94
95
|
signing_key:
|
95
96
|
specification_version: 4
|
96
97
|
summary: Rails Batch Request API.
|