rack-cargo 0.9.1 → 1.0.0
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/.travis.yml +2 -2
- data/README.md +15 -5
- data/lib/rack/cargo/reference_resolver.rb +2 -0
- data/lib/rack/cargo/request_env_builder.rb +21 -8
- data/lib/rack/cargo/response_builder.rb +1 -0
- data/lib/rack/cargo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 048340003319fa2ae901fbdbb95093b0350aa6a5
|
4
|
+
data.tar.gz: 1ab67a556f070ed792dacf24a0be83f989eb6bdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8b80851dd86f64cdff6360f1b495b4e46ec6344cefc6bfc46ccd81d7d52d95e96b39a52393cfa056c1878875d71e222fbf19050de24352a0a15260bbf81dc6e
|
7
|
+
data.tar.gz: 2cae3f111f66c09a810f88cf3eed7045aa21584db941f43a6b76041b2878b2b70d4a8aebdebf64b3744e83a22829345f5f42548f9d8e9c52c5b3ad08f7649716
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -32,7 +32,9 @@ Or install it yourself as:
|
|
32
32
|
|
33
33
|
$ gem install rack-cargo
|
34
34
|
|
35
|
-
## Usage
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
Regarding individual requests, `rack-cargo` tries to follow the [Rack SPEC](https://www.rubydoc.info/github/rack/rack/file/SPEC). If you find any mismatches, feel free to open an issue or a pull request.
|
36
38
|
|
37
39
|
### Configuration
|
38
40
|
|
@@ -139,14 +141,14 @@ module MyFeeder
|
|
139
141
|
state.store(:data, "Useful data to MyEater")
|
140
142
|
end
|
141
143
|
end
|
142
|
-
|
144
|
+
|
143
145
|
module MyEater
|
144
146
|
def self.call(request, state)
|
145
147
|
data = state.fetch(:data)
|
146
148
|
# do something with the data
|
147
149
|
end
|
148
150
|
end
|
149
|
-
|
151
|
+
|
150
152
|
Rack::Cargo.configure do |config|
|
151
153
|
config.processors.insert(2, MyFeeder) # insert into third position
|
152
154
|
config.processors.insert(3, MyEater) # insert into fourth position
|
@@ -169,6 +171,14 @@ end
|
|
169
171
|
|
170
172
|
Timed out requests' response is with status 504 (Gateway timeout) and with empty headers, body.
|
171
173
|
|
174
|
+
### `nil` body in an individual request
|
175
|
+
|
176
|
+
In case an individual requests' body is `nil`, it will be sent downstream as `""` (empty `String`).
|
177
|
+
|
178
|
+
### No body in an individual response
|
179
|
+
|
180
|
+
In case an individual request receives a response without a body (as empty `String`), it will be sent upstream as `nil`.
|
181
|
+
|
172
182
|
## Development
|
173
183
|
|
174
184
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -177,7 +187,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
177
187
|
|
178
188
|
## Contributing
|
179
189
|
|
180
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
190
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/murdho/rack-cargo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
181
191
|
|
182
192
|
## License
|
183
193
|
|
@@ -185,4 +195,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
185
195
|
|
186
196
|
## Code of Conduct
|
187
197
|
|
188
|
-
Everyone interacting in the Rack::Cargo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
198
|
+
Everyone interacting in the Rack::Cargo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/murdho/rack-cargo/blob/master/CODE_OF_CONDUCT.md).
|
@@ -12,6 +12,8 @@ module Rack
|
|
12
12
|
class << self
|
13
13
|
def call(request, state)
|
14
14
|
REFERENCING_ENABLED.each do |attribute_key|
|
15
|
+
next if request.fetch(attribute_key).nil?
|
16
|
+
|
15
17
|
element, converted_to_json = get_json_element(request, attribute_key)
|
16
18
|
placeholders = find_placeholders(element)
|
17
19
|
|
@@ -5,16 +5,29 @@ require "rack/cargo/core_ext/deep_dup"
|
|
5
5
|
module Rack
|
6
6
|
module Cargo
|
7
7
|
module RequestEnvBuilder
|
8
|
-
|
9
|
-
|
8
|
+
class << self
|
9
|
+
def call(request, state)
|
10
|
+
request_env = state.fetch(:env).deep_dup
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
path, query_string = request[REQUEST_PATH].split("?", 2)
|
13
|
+
request_env[ENV_PATH] = path
|
14
|
+
request_env[ENV_QUERY_STRING] = query_string || ""
|
15
|
+
request_env[ENV_METHOD] = request[REQUEST_METHOD]
|
16
|
+
request_env[ENV_INPUT] = StringIO.new(
|
17
|
+
io_input_from_request_body(request[REQUEST_BODY])
|
18
|
+
)
|
16
19
|
|
17
|
-
|
20
|
+
state[:request_env] = request_env
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Returns request_body as JSON if it's not nil,
|
26
|
+
# otherwise returns empty string.
|
27
|
+
def io_input_from_request_body(request_body)
|
28
|
+
return "" if request_body.nil?
|
29
|
+
request_body.to_json
|
30
|
+
end
|
18
31
|
end
|
19
32
|
end
|
20
33
|
end
|
data/lib/rack/cargo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-cargo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Murdho
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|