api-blueprint 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/api-blueprint/cache.rb +3 -2
- data/lib/api-blueprint/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3b301a57079985d9709f72b0ad1dfe1310e78c
|
4
|
+
data.tar.gz: efd1ede63552fa9489d09b9f45b13cec682e85e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a5732ab57a0b4f02af8f37c2c82571ccd4a3072665272f9d42a6cf30081cb618e9a2f3d33f2900142dc727518f89cb296ec5db0454653564389198959a5a159
|
7
|
+
data.tar.gz: 9ff4723a7a24304da190b4540ff3e277e011faffda39d238da7a638403f59f78fcb8386fbdd4e17220caae358f5da4c6cca71679d2c95f9f42158bd6af903aef
|
data/README.md
CHANGED
@@ -254,12 +254,13 @@ ApiBlueprint::Runner.new({
|
|
254
254
|
})
|
255
255
|
```
|
256
256
|
|
257
|
-
The `ApiBlueprint::Cache` class has a method to generate unique keys for the cache items by creating a checksum of the request headers and url. It doesn't include the body of the request in this checksum by default, and if you want to exclude
|
257
|
+
The `ApiBlueprint::Cache` class has a method to generate unique keys for the cache items by creating a checksum of the request headers and url. It doesn't include the body of the request in this checksum by default, and if you want to exclude headers, you can do so using the `ignored_headers` setting on the Cache class.
|
258
|
+
|
259
|
+
For example, to not include "X-Real-IP" and "X-Request-Id" headers, which would otherwise render the cache useless:
|
258
260
|
|
259
261
|
```ruby
|
260
262
|
ApiBlueprint::Cache.configure do |config|
|
261
|
-
|
262
|
-
config.ignored_headers.concat ["X-Real-IP", "X-Request-Id"]
|
263
|
+
config.ignored_headers = ["X-Real-IP", "X-Request-Id"]
|
263
264
|
end
|
264
265
|
```
|
265
266
|
|
data/lib/api-blueprint/cache.rb
CHANGED
@@ -3,7 +3,7 @@ module ApiBlueprint
|
|
3
3
|
extend Dry::Initializer
|
4
4
|
extend Dry::Configurable
|
5
5
|
|
6
|
-
setting :ignored_headers, [
|
6
|
+
setting :ignored_headers, []
|
7
7
|
|
8
8
|
option :key
|
9
9
|
|
@@ -21,7 +21,8 @@ module ApiBlueprint
|
|
21
21
|
|
22
22
|
def generate_cache_key(klass, options)
|
23
23
|
if options.is_a? Hash
|
24
|
-
options = options.clone.with_indifferent_access.except
|
24
|
+
options = options.clone.with_indifferent_access.except :body
|
25
|
+
options[:headers] = options[:headers].except *self.class.config.ignored_headers if options[:headers]
|
25
26
|
end
|
26
27
|
|
27
28
|
options_digest = Digest::MD5.hexdigest Marshal::dump(options.to_s.chars.sort.join)
|