grape 1.1.0 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +128 -43
  3. data/LICENSE +1 -1
  4. data/README.md +394 -47
  5. data/UPGRADING.md +111 -0
  6. data/grape.gemspec +3 -1
  7. data/lib/grape.rb +98 -66
  8. data/lib/grape/api.rb +136 -175
  9. data/lib/grape/api/instance.rb +280 -0
  10. data/lib/grape/config.rb +32 -0
  11. data/lib/grape/dsl/callbacks.rb +20 -0
  12. data/lib/grape/dsl/desc.rb +39 -7
  13. data/lib/grape/dsl/inside_route.rb +12 -6
  14. data/lib/grape/dsl/middleware.rb +7 -0
  15. data/lib/grape/dsl/parameters.rb +9 -4
  16. data/lib/grape/dsl/routing.rb +5 -1
  17. data/lib/grape/dsl/validations.rb +4 -3
  18. data/lib/grape/eager_load.rb +18 -0
  19. data/lib/grape/endpoint.rb +42 -26
  20. data/lib/grape/error_formatter.rb +1 -1
  21. data/lib/grape/exceptions/base.rb +9 -1
  22. data/lib/grape/exceptions/invalid_response.rb +9 -0
  23. data/lib/grape/exceptions/validation_errors.rb +4 -2
  24. data/lib/grape/formatter.rb +1 -1
  25. data/lib/grape/locale/en.yml +2 -0
  26. data/lib/grape/middleware/auth/base.rb +2 -4
  27. data/lib/grape/middleware/base.rb +2 -0
  28. data/lib/grape/middleware/error.rb +9 -4
  29. data/lib/grape/middleware/helpers.rb +10 -0
  30. data/lib/grape/middleware/stack.rb +1 -1
  31. data/lib/grape/middleware/versioner/header.rb +4 -4
  32. data/lib/grape/parser.rb +1 -1
  33. data/lib/grape/request.rb +1 -1
  34. data/lib/grape/router/attribute_translator.rb +2 -0
  35. data/lib/grape/router/route.rb +2 -2
  36. data/lib/grape/util/base_inheritable.rb +34 -0
  37. data/lib/grape/util/endpoint_configuration.rb +6 -0
  38. data/lib/grape/util/inheritable_values.rb +5 -25
  39. data/lib/grape/util/lazy_block.rb +25 -0
  40. data/lib/grape/util/lazy_value.rb +95 -0
  41. data/lib/grape/util/reverse_stackable_values.rb +7 -36
  42. data/lib/grape/util/stackable_values.rb +19 -22
  43. data/lib/grape/validations/attributes_iterator.rb +5 -3
  44. data/lib/grape/validations/multiple_attributes_iterator.rb +11 -0
  45. data/lib/grape/validations/params_scope.rb +20 -14
  46. data/lib/grape/validations/single_attribute_iterator.rb +13 -0
  47. data/lib/grape/validations/types/custom_type_coercer.rb +1 -1
  48. data/lib/grape/validations/types/file.rb +1 -1
  49. data/lib/grape/validations/validator_factory.rb +6 -11
  50. data/lib/grape/validations/validators/all_or_none.rb +6 -13
  51. data/lib/grape/validations/validators/as.rb +2 -3
  52. data/lib/grape/validations/validators/at_least_one_of.rb +5 -13
  53. data/lib/grape/validations/validators/base.rb +11 -10
  54. data/lib/grape/validations/validators/coerce.rb +4 -0
  55. data/lib/grape/validations/validators/default.rb +1 -1
  56. data/lib/grape/validations/validators/exactly_one_of.rb +6 -23
  57. data/lib/grape/validations/validators/multiple_params_base.rb +14 -10
  58. data/lib/grape/validations/validators/mutual_exclusion.rb +6 -18
  59. data/lib/grape/validations/validators/same_as.rb +23 -0
  60. data/lib/grape/version.rb +1 -1
  61. data/spec/grape/api/defines_boolean_in_params_spec.rb +37 -0
  62. data/spec/grape/api/routes_with_requirements_spec.rb +59 -0
  63. data/spec/grape/api_remount_spec.rb +466 -0
  64. data/spec/grape/api_spec.rb +379 -1
  65. data/spec/grape/config_spec.rb +17 -0
  66. data/spec/grape/dsl/desc_spec.rb +40 -16
  67. data/spec/grape/dsl/middleware_spec.rb +8 -0
  68. data/spec/grape/dsl/routing_spec.rb +10 -0
  69. data/spec/grape/endpoint_spec.rb +40 -4
  70. data/spec/grape/exceptions/base_spec.rb +65 -0
  71. data/spec/grape/exceptions/invalid_response_spec.rb +11 -0
  72. data/spec/grape/exceptions/validation_errors_spec.rb +6 -4
  73. data/spec/grape/integration/rack_spec.rb +22 -6
  74. data/spec/grape/middleware/auth/dsl_spec.rb +3 -3
  75. data/spec/grape/middleware/base_spec.rb +8 -0
  76. data/spec/grape/middleware/exception_spec.rb +1 -1
  77. data/spec/grape/middleware/formatter_spec.rb +15 -5
  78. data/spec/grape/middleware/versioner/header_spec.rb +6 -0
  79. data/spec/grape/named_api_spec.rb +19 -0
  80. data/spec/grape/request_spec.rb +24 -0
  81. data/spec/grape/validations/multiple_attributes_iterator_spec.rb +29 -0
  82. data/spec/grape/validations/params_scope_spec.rb +184 -8
  83. data/spec/grape/validations/single_attribute_iterator_spec.rb +33 -0
  84. data/spec/grape/validations/validators/all_or_none_spec.rb +138 -30
  85. data/spec/grape/validations/validators/at_least_one_of_spec.rb +173 -29
  86. data/spec/grape/validations/validators/coerce_spec.rb +10 -2
  87. data/spec/grape/validations/validators/exactly_one_of_spec.rb +202 -38
  88. data/spec/grape/validations/validators/mutual_exclusion_spec.rb +184 -27
  89. data/spec/grape/validations/validators/same_as_spec.rb +63 -0
  90. data/spec/grape/validations_spec.rb +33 -21
  91. data/spec/spec_helper.rb +4 -1
  92. metadata +35 -23
  93. data/Appraisals +0 -32
  94. data/Dangerfile +0 -2
  95. data/Gemfile +0 -33
  96. data/Gemfile.lock +0 -231
  97. data/Guardfile +0 -10
  98. data/RELEASING.md +0 -111
  99. data/Rakefile +0 -25
  100. data/benchmark/simple.rb +0 -27
  101. data/benchmark/simple_with_type_coercer.rb +0 -22
  102. data/gemfiles/multi_json.gemfile +0 -35
  103. data/gemfiles/multi_xml.gemfile +0 -35
  104. data/gemfiles/rack_1.5.2.gemfile +0 -35
  105. data/gemfiles/rack_edge.gemfile +0 -35
  106. data/gemfiles/rails_3.gemfile +0 -36
  107. data/gemfiles/rails_4.gemfile +0 -35
  108. data/gemfiles/rails_5.gemfile +0 -35
  109. data/gemfiles/rails_edge.gemfile +0 -35
  110. data/pkg/grape-0.17.0.gem +0 -0
  111. data/pkg/grape-0.19.0.gem +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7768f2318b0b1045ec81b3a83cb08b5d80676da77aaa30f059fb056175578781
4
- data.tar.gz: e19ecc4e39b33a19e43e7831ceab4d5a13fd186677cef84547066e48d24d98d0
3
+ metadata.gz: 8934b2070d7c44a7100315712c05ee9e76eff602290b30f475f6e2e324c5392c
4
+ data.tar.gz: 0d618a852be97bf103c7f783702342b030440834fedd725b4e6a90e03a8b0556
5
5
  SHA512:
6
- metadata.gz: afc16b3f2a5036029bb22615ded000eefb2c24f396efa1f2bc22b253bb84d1adb2a4f2ea7dad63a8d4f98a0c69e7720b828072e57bd8e5ce281c1d158f25cb02
7
- data.tar.gz: b650ba30bc697feea23a4aa03a50e525b135e25c14707b85f4e95b7a95c5ba37e1565ddce147148885467516c1a7d48e74d58cabb1172679978dcbe28216674a
6
+ metadata.gz: f11c651eb7dea86dd45065c04cdebcbb2635cf8136536850b245d4ad94eac921a4218f191cc5f523968cdc4708ee7ede49fce17de21b97b96edcd82426c06795
7
+ data.tar.gz: 8266b0bf359c1ed96b7aacd9bbecacfe6ef5f406b94d54a1a9c6dfdbf18d95967f8c853f13dfab642631e261f81893bcc5323e83c0d27a04226bdc03d7b19381
@@ -1,11 +1,96 @@
1
- ### 1.1.0 (8/4/2018)
1
+ ### 1.2.5 (2019/12/01)
2
2
 
3
3
  #### Features
4
4
 
5
- * [#1759](https://github.com/ruby-grape/grape/pull/1759): Instrument serialization as `'format_response.grape'` - [@zvkemp](https://github.com/zvkemp).
5
+ * [#1931](https://github.com/ruby-grape/grape/pull/1931): Introduces LazyBlock to generate expressions that will executed at mount time - [@myxoh](https://github.com/myxoh).
6
+ * [#1918](https://github.com/ruby-grape/grape/pull/1918): Helper methods to access controller context from middleware - [@NikolayRys](https://github.com/NikolayRys).
7
+ * [#1915](https://github.com/ruby-grape/grape/pull/1915): Micro optimizations in allocating hashes and arrays - [@dnesteryuk](https://github.com/dnesteryuk).
8
+ * [#1904](https://github.com/ruby-grape/grape/pull/1904): Allows Grape to load files on startup rather than on the first call - [@myxoh](https://github.com/myxoh).
9
+ * [#1907](https://github.com/ruby-grape/grape/pull/1907): Adds outside configuration to Grape with `configure` - [@unleashy](https://github.com/unleashy).
10
+ * [#1914](https://github.com/ruby-grape/grape/pull/1914): Run specs in random order - [@splattael](https://github.com/splattael).
11
+
12
+ #### Fixes
13
+
14
+ * [#1917](https://github.com/ruby-grape/grape/pull/1917): Update access to rack constant - [@NikolayRys](https://github.com/NikolayRys).
15
+ * [#1916](https://github.com/ruby-grape/grape/pull/1916): Drop old appraisals - [@NikolayRys](https://github.com/NikolayRys).
16
+ * [#1911](https://github.com/ruby-grape/grape/pull/1911): Make sure `Grape::Valiations::AtLeastOneOfValidator` properly treats nested params in errors - [@dnesteryuk](https://github.com/dnesteryuk).
17
+ * [#1893](https://github.com/ruby-grape/grape/pull/1893): Allows `Grape::API` to behave like a Rack::app in some instances where it was misbehaving - [@myxoh](https://github.com/myxoh).
18
+ * [#1898](https://github.com/ruby-grape/grape/pull/1898): Refactor `ValidatorFactory` to improve memory allocation - [@Bhacaz](https://github.com/Bhacaz).
19
+ * [#1900](https://github.com/ruby-grape/grape/pull/1900): Define boolean for `Grape::Api::Instance` - [@Bhacaz](https://github.com/Bhacaz).
20
+ * [#1903](https://github.com/ruby-grape/grape/pull/1903): Allow nested params renaming (Hash/Array) - [@bikolya](https://github.com/bikolya).
21
+ * [#1913](https://github.com/ruby-grape/grape/pull/1913): Fix multiple params validators to return correct messages for nested params - [@bikolya](https://github.com/bikolya).
22
+ * [#1926](https://github.com/ruby-grape/grape/pull/1926): Fixes configuration within given or mounted blocks - [@myxoh](https://github.com/myxoh).
23
+ * [#1937](https://github.com/ruby-grape/grape/pull/1937): Fix bloat in released gem - [@dblock](https://github.com/dblock).
24
+
25
+ ### 1.2.4 (2019/06/13)
26
+
27
+ #### Features
28
+
29
+ * [#1888](https://github.com/ruby-grape/grape/pull/1888): Makes the `configuration` hash widely available - [@myxoh](https://github.com/myxoh).
30
+ * [#1864](https://github.com/ruby-grape/grape/pull/1864): Adds `finally` on the API - [@myxoh](https://github.com/myxoh).
31
+ * [#1869](https://github.com/ruby-grape/grape/pull/1869): Fix issue with empty headers after `error!` method call - [@anaumov](https://github.com/anaumov).
32
+
33
+ #### Fixes
34
+
35
+ * [#1868](https://github.com/ruby-grape/grape/pull/1868): Fix NoMethodError with none hash params - [@ksss](https://github.com/ksss).
36
+ * [#1876](https://github.com/ruby-grape/grape/pull/1876): Fix const errors being hidden by bug in `const_missing` - [@dandehavilland](https://github.com/dandehavilland).
37
+
38
+ ### 1.2.3 (2019/01/16)
39
+
40
+ #### Features
41
+
42
+ * [#1850](https://github.com/ruby-grape/grape/pull/1850): Adds `same_as` validator - [@glaucocustodio](https://github.com/glaucocustodio).
43
+ * [#1833](https://github.com/ruby-grape/grape/pull/1833): Allows to set the `ParamBuilder` globally - [@myxoh](https://github.com/myxoh).
44
+
45
+ #### Fixes
46
+
47
+ * [#1852](https://github.com/ruby-grape/grape/pull/1852): `allow_blank` called after `as` when the original param is not blank - [@glaucocustodio](https://github.com/glaucocustodio).
48
+ * [#1844](https://github.com/ruby-grape/grape/pull/1844): Enforce `:tempfile` to be a `Tempfile` object in `File` validator - [@Nyangawa](https://github.com/Nyangawa).
49
+
50
+ ### 1.2.2 (2018/12/07)
51
+
52
+ #### Features
53
+
54
+ * [#1832](https://github.com/ruby-grape/grape/pull/1832): Support `body_name` in `desc` block - [@fotos](https://github.com/fotos).
55
+ * [#1831](https://github.com/ruby-grape/grape/pull/1831): Support `security` in `desc` block - [@fotos](https://github.com/fotos).
56
+
57
+ #### Fixes
58
+
59
+ * [#1836](https://github.com/ruby-grape/grape/pull/1836): Fix: memory leak not releasing `call` method calls from setup - [@myxoh](https://github.com/myxoh).
60
+ * [#1830](https://github.com/ruby-grape/grape/pull/1830), [#1829](https://github.com/ruby-grape/grape/issues/1829): Restores `self` sanity - [@myxoh](https://github.com/myxoh).
61
+
62
+ ### 1.2.1 (2018/11/28)
63
+
64
+ #### Fixes
65
+
66
+ * [#1825](https://github.com/ruby-grape/grape/pull/1825): `to_s` on a mounted class now responses with the API name - [@myxoh](https://github.com/myxoh).
67
+
68
+ ### 1.2.0 (2018/11/26)
69
+
70
+ #### Features
71
+
72
+ * [#1813](https://github.com/ruby-grape/grape/pull/1813): Add ruby 2.5 support, drop 2.2. Update rails version in travis - [@darren987469](https://github.com/darren987469).
73
+ * [#1803](https://github.com/ruby-grape/grape/pull/1803): Adds the ability to re-mount all endpoints in any location - [@myxoh](https://github.com/myxoh).
74
+ * [#1795](https://github.com/ruby-grape/grape/pull/1795): Fix vendor/subtype parsing of an invalid Accept header - [@bschmeck](https://github.com/bschmeck).
75
+ * [#1791](https://github.com/ruby-grape/grape/pull/1791): Support `summary`, `hidden`, `deprecated`, `is_array`, `nickname`, `produces`, `consumes`, `tags` options in `desc` block - [@darren987469](https://github.com/darren987469).
6
76
 
7
77
  #### Fixes
8
78
 
79
+ * [#1796](https://github.com/ruby-grape/grape/pull/1796): Fix crash when available locales are enforced but fallback locale unavailable - [@Morred](https://github.com/Morred).
80
+ * [#1776](https://github.com/ruby-grape/grape/pull/1776): Validate response returned by the exception handler - [@darren987469](https://github.com/darren987469).
81
+ * [#1787](https://github.com/ruby-grape/grape/pull/1787): Add documented but not implemented ability to `.insert` a middleware in the stack - [@michaellennox](https://github.com/michaellennox).
82
+ * [#1788](https://github.com/ruby-grape/grape/pull/1788): Fix route requirements bug - [@darren987469](https://github.com/darren987469), [@darrellnash](https://github.com/darrellnash).
83
+ * [#1810](https://github.com/ruby-grape/grape/pull/1810): Fix support in `given` for aliased params - [@darren987469](https://github.com/darren987469).
84
+ * [#1811](https://github.com/ruby-grape/grape/pull/1811): Support nested dependent parameters - [@darren987469](https://github.com/darren987469), [@andreacfm](https://github.com/andreacfm).
85
+ * [#1822](https://github.com/ruby-grape/grape/pull/1822): Raise validation error when optional hash type parameter is received string type value and exactly_one_of be used - [@woshidan](https://github.com/woshidan).
86
+
87
+ ### 1.1.0 (2018/8/4)
88
+
89
+ #### Features
90
+
91
+ * [#1759](https://github.com/ruby-grape/grape/pull/1759): Instrument serialization as `'format_response.grape'` - [@zvkemp](https://github.com/zvkemp).
92
+
93
+ #### Fixes
9
94
 
10
95
  * [#1762](https://github.com/ruby-grape/grape/pull/1763): Fix unsafe HTML rendering on errors - [@ctennis](https://github.com/ctennis).
11
96
  * [#1759](https://github.com/ruby-grape/grape/pull/1759): Update appraisal for rails_edge - [@zvkemp](https://github.com/zvkemp).
@@ -13,7 +98,7 @@
13
98
  * [#1765](https://github.com/ruby-grape/grape/pull/1765): Use 415 when request body is of an unsupported media type - [@jdmurphy](https://github.com/jdmurphy).
14
99
  * [#1771](https://github.com/ruby-grape/grape/pull/1771): Fix param aliases with 'given' blocks - [@jereynolds](https://github.com/jereynolds).
15
100
 
16
- ### 1.0.3 (4/23/2018)
101
+ ### 1.0.3 (2018/4/23)
17
102
 
18
103
  #### Fixes
19
104
 
@@ -26,7 +111,7 @@
26
111
  * [#1754](https://github.com/ruby-grape/grape/pull/1754): Allow rescue from non-`StandardError` exceptions to use default error handling - [@jelkster](https://github.com/jelkster).
27
112
  * [#1756](https://github.com/ruby-grape/grape/pull/1756): Allow custom Grape exception handlers when the built-in exception handling is enabled - [@soylent](https://github.com/soylent).
28
113
 
29
- ### 1.0.2 (1/10/2018)
114
+ ### 1.0.2 (2018/1/10)
30
115
 
31
116
  #### Features
32
117
 
@@ -44,7 +129,7 @@
44
129
  * [#1726](https://github.com/ruby-grape/grape/pull/1726): Improved startup performance during API method generation - [@jkowens](https://github.com/jkowens).
45
130
  * [#1727](https://github.com/ruby-grape/grape/pull/1727): Fix infinite loop when mounting endpoint with same superclass - [@jkowens](https://github.com/jkowens).
46
131
 
47
- ### 1.0.1 (9/8/2017)
132
+ ### 1.0.1 (2017/9/8)
48
133
 
49
134
  #### Features
50
135
 
@@ -58,7 +143,7 @@
58
143
  * [#1661](https://github.com/ruby-grape/grape/pull/1661): Handle deeply-nested dependencies correctly - [@rnubel](https://github.com/rnubel), [@jnardone](https://github.com/jnardone).
59
144
  * [#1679](https://github.com/ruby-grape/grape/pull/1679): Treat StandardError from explicit values validator proc as false - [@jlfaber](https://github.com/jlfaber).
60
145
 
61
- ### 1.0.0 (7/3/2017)
146
+ ### 1.0.0 (2017/7/3)
62
147
 
63
148
  #### Features
64
149
 
@@ -77,7 +162,7 @@
77
162
  * [#1625](https://github.com/ruby-grape/grape/pull/1625): Handle `given` correctly when nested in Array params - [@rnubel](https://github.com/rnubel), [@avellable](https://github.com/avellable).
78
163
  * [#1649](https://github.com/ruby-grape/grape/pull/1649): Don't share validator instances between requests - [@anakinj](https://github.com/anakinj).
79
164
 
80
- ### 0.19.2 (4/12/2017)
165
+ ### 0.19.2 (2017/4/12)
81
166
 
82
167
  #### Features
83
168
 
@@ -98,7 +183,7 @@
98
183
  * [#1569](https://github.com/ruby-grape/grape/pull/1569), [#1511](https://github.com/ruby-grape/grape/issues/1511): Upgrade mustermann-grape to 1.0.0 - [@namusyaka](https://github.com/namusyaka).
99
184
  * [#1589](https://github.com/ruby-grape/grape/pull/1589): [#726](https://github.com/ruby-grape/grape/issues/726): Use default_format when Content-type is missing and respond with 406 when Content-type is invalid - [@inclooder](https://github.com/inclooder).
100
185
 
101
- ### 0.19.1 (1/9/2017)
186
+ ### 0.19.1 (2017/1/9)
102
187
 
103
188
  #### Features
104
189
 
@@ -110,7 +195,7 @@
110
195
  * [#1548](https://github.com/ruby-grape/grape/pull/1548): Fix: avoid failing even if given path does not match with prefix - [@thomas-peyric](https://github.com/thomas-peyric), [@namusyaka](https://github.com/namusyaka).
111
196
  * [#1550](https://github.com/ruby-grape/grape/pull/1550): Fix: return 200 as default status for DELETE - [@jthornec](https://github.com/jthornec).
112
197
 
113
- ### 0.19.0 (12/18/2016)
198
+ ### 0.19.0 (2016/12/18)
114
199
 
115
200
  #### Features
116
201
 
@@ -126,7 +211,7 @@
126
211
  * [#1510](https://github.com/ruby-grape/grape/pull/1510): Fix: inconsistent validation for multiple parameters - [@dgasper](https://github.com/dgasper).
127
212
  * [#1526](https://github.com/ruby-grape/grape/pull/1526): Reduced warnings caused by instance variables not initialized - [@cpetschnig](https://github.com/cpetschnig).
128
213
 
129
- ### 0.18.0 (10/7/2016)
214
+ ### 0.18.0 (2016/10/7)
130
215
 
131
216
  #### Features
132
217
 
@@ -143,7 +228,7 @@
143
228
  * [#1488](https://github.com/ruby-grape/grape/pull/1488): Fix: ensure calling before filters when receiving OPTIONS request - [@namusyaka](https://github.com/namusyaka), [@jlfaber](https://github.com/jlfaber).
144
229
  * [#1493](https://github.com/ruby-grape/grape/pull/1493): Fix: coercion and lambda fails params validation - [@jonmchan](https://github.com/jonmchan).
145
230
 
146
- ### 0.17.0 (7/29/2016)
231
+ ### 0.17.0 (2016/7/29)
147
232
 
148
233
  #### Features
149
234
 
@@ -170,7 +255,7 @@
170
255
  * [#1421](https://github.com/ruby-grape/grape/pull/1421): Avoid polluting `Grape::Middleware::Error` - [@namusyaka](https://github.com/namusyaka).
171
256
  * [#1422](https://github.com/ruby-grape/grape/pull/1422): Concat parent declared params with current one - [@plukevdh](https://github.com/plukevdh), [@rnubel](https://github.com/rnubel), [@namusyaka](https://github.com/namusyaka).
172
257
 
173
- ### 0.16.2 (4/12/2016)
258
+ ### 0.16.2 (2016/4/12)
174
259
 
175
260
  #### Features
176
261
 
@@ -183,7 +268,7 @@
183
268
  * [#1359](https://github.com/ruby-grape/grape/pull/1359): Avoid evaluating the same route twice - [@namusyaka](https://github.com/namusyaka), [@dblock](https://github.com/dblock).
184
269
  * [#1361](https://github.com/ruby-grape/grape/pull/1361): Return 405 correctly even if version is using as header and wrong request method - [@namusyaka](https://github.com/namusyaka), [@dblock](https://github.com/dblock).
185
270
 
186
- ### 0.16.1 (4/3/2016)
271
+ ### 0.16.1 (2016/4/3)
187
272
 
188
273
  #### Features
189
274
 
@@ -198,7 +283,7 @@
198
283
  * [#1330](https://github.com/ruby-grape/grape/pull/1330): Add `register` keyword for adding customized parsers and formatters - [@namusyaka](https://github.com/namusyaka).
199
284
  * [#1336](https://github.com/ruby-grape/grape/pull/1336): Do not modify Hash argument to `error!` - [@tjwp](https://github.com/tjwp).
200
285
 
201
- ### 0.15.0 (3/8/2016)
286
+ ### 0.15.0 (2016/3/8)
202
287
 
203
288
  #### Features
204
289
 
@@ -225,7 +310,7 @@
225
310
  * [#1283](https://github.com/ruby-grape/grape/pull/1283): Fix 500 error for xml format when method is not allowed - [@304](https://github.com/304).
226
311
  * [#1197](https://github.com/ruby-grape/grape/pull/1290): Fix using JSON and Array[JSON] as groups when parameter is optional - [@lukeivers](https://github.com/lukeivers).
227
312
 
228
- ### 0.14.0 (12/07/2015)
313
+ ### 0.14.0 (2015/12/07)
229
314
 
230
315
  #### Features
231
316
 
@@ -252,7 +337,7 @@
252
337
  * [#1101](https://github.com/ruby-grape/grape/pull/1101): Fix: Incorrect media-type `Accept` header now correctly returns 406 with `strict: true` - [@elliotlarson](https://github.com/elliotlarson).
253
338
  * [#1108](https://github.com/ruby-grape/grape/pull/1039): Raise a warning when `desc` is called with options hash and block - [@rngtng](https://github.com/rngtng).
254
339
 
255
- ### 0.13.0 (8/10/2015)
340
+ ### 0.13.0 (2015/8/10)
256
341
 
257
342
  #### Features
258
343
 
@@ -273,7 +358,7 @@
273
358
  * [#1088](https://github.com/ruby-grape/grape/pull/1088): Support ActiveSupport 3.x by explicitly requiring `Hash#except` - [@wagenet](https://github.com/wagenet).
274
359
  * [#1096](https://github.com/ruby-grape/grape/pull/1096): Fix coercion on booleans - [@towanda](https://github.com/towanda).
275
360
 
276
- ### 0.12.0 (6/18/2015)
361
+ ### 0.12.0 (2015/6/18)
277
362
 
278
363
  #### Features
279
364
 
@@ -299,7 +384,7 @@
299
384
  * [#1023](https://github.com/ruby-grape/grape/issues/1023): Fixes unexpected behavior with `present` and an object that responds to `merge` but isn't a Hash - [@dblock](https://github.com/dblock).
300
385
  * [#1017](https://github.com/ruby-grape/grape/pull/1017): Fixed `undefined method stringify_keys` with nested mutual exclusive params - [@quickpay](https://github.com/quickpay).
301
386
 
302
- ### 0.11.0 (2/23/2015)
387
+ ### 0.11.0 (2015/2/23)
303
388
 
304
389
  * [#925](https://github.com/ruby-grape/grape/pull/925): Fixed `toplevel constant DateTime referenced by Virtus::Attribute::DateTime` - [@u2](https://github.com/u2).
305
390
  * [#916](https://github.com/ruby-grape/grape/pull/916): Added `DateTime/Date/Numeric/Boolean` type support `allow_blank` - [@u2](https://github.com/u2).
@@ -316,12 +401,12 @@
316
401
  * [#913](https://github.com/ruby-grape/grape/pull/913): Fix: Invalid accept headers cause internal processing errors (500) when http_codes are defined - [@croeck](https://github.com/croeck).
317
402
  * [#917](https://github.com/ruby-grape/grape/pull/917): Use HTTPS for rubygems.org - [@O-I](https://github.com/O-I).
318
403
 
319
- ### 0.10.1 (12/28/2014)
404
+ ### 0.10.1 (2014/12/28)
320
405
 
321
406
  * [#868](https://github.com/ruby-grape/grape/pull/868), [#862](https://github.com/ruby-grape/grape/pull/862), [#861](https://github.com/ruby-grape/grape/pull/861): Fixed `version`, `prefix`, and other settings being overridden or changing scope when mounting API - [@yesmeck](https://github.com/yesmeck).
322
407
  * [#864](https://github.com/ruby-grape/grape/pull/864): Fixed `declared(params, include_missing: false)` now returning attributes with `nil` and `false` values - [@ppadron](https://github.com/ppadron).
323
408
 
324
- ### 0.10.0 (12/19/2014)
409
+ ### 0.10.0 (2014/12/19)
325
410
 
326
411
  * [#803](https://github.com/ruby-grape/grape/pull/803), [#820](https://github.com/ruby-grape/grape/pull/820): Added `all_or_none_of` parameter validator - [@loveltyoic](https://github.com/loveltyoic), [@natecj](https://github.com/natecj).
327
412
  * [#774](https://github.com/ruby-grape/grape/pull/774): Extended `mutually_exclusive`, `exactly_one_of`, `at_least_one_of` to work inside any kind of group: `requires` or `optional`, `Hash` or `Array` - [@ShPakvel](https://github.com/ShPakvel).
@@ -344,7 +429,7 @@
344
429
  * [#679](https://github.com/ruby-grape/grape/issues/679): Fixed `OPTIONS` method returning 404 when combined with `prefix` - [@dblock](https://github.com/dblock).
345
430
  * [#679](https://github.com/ruby-grape/grape/issues/679): Fixed unsupported methods returning 404 instead of 405 when combined with `prefix` - [@dblock](https://github.com/dblock).
346
431
 
347
- ### 0.9.0 (8/27/2014)
432
+ ### 0.9.0 (2014/8/27)
348
433
 
349
434
  #### Features
350
435
 
@@ -362,7 +447,7 @@
362
447
 
363
448
  * [#687](https://github.com/ruby-grape/grape/pull/687): Fix: `mutually_exclusive` and `exactly_one_of` validation error messages now label parameters as strings, consistently with `requires` and `optional` - [@dblock](https://github.com/dblock).
364
449
 
365
- ### 0.8.0 (7/10/2014)
450
+ ### 0.8.0 (2014/7/10)
366
451
 
367
452
  #### Features
368
453
 
@@ -382,7 +467,7 @@
382
467
  * [#619](https://github.com/ruby-grape/grape/pull/619): Convert specs to RSpec 3 syntax with Transpec - [@danielspector](https://github.com/danielspector).
383
468
  * [#632](https://github.com/ruby-grape/grape/pull/632): `Grape::Endpoint#present` causes ActiveRecord to make an extra query during entity's detection - [@fixme](https://github.com/fixme).
384
469
 
385
- ### 0.7.0 (4/2/2014)
470
+ ### 0.7.0 (2014/4/2)
386
471
 
387
472
  #### Features
388
473
 
@@ -421,7 +506,7 @@
421
506
  * [#587](https://github.com/ruby-grape/grape/pull/587): Fix oauth2 middleware compatibility with [draft-ietf-oauth-v2-31](http://tools.ietf.org/html/draft-ietf-oauth-v2-31) spec - [@etehtsea](https://github.com/etehtsea).
422
507
  * [#610](https://github.com/ruby-grape/grape/pull/610): Fixed group keyword was not working with type parameter - [@klausmeyer](https://github.com/klausmeyer).
423
508
 
424
- ### 0.6.1 (10/19/2013)
509
+ ### 0.6.1 (2013/10/19)
425
510
 
426
511
  #### Features
427
512
 
@@ -437,7 +522,7 @@
437
522
 
438
523
  * Implemented Rubocop, a Ruby code static code analyzer - [@dblock](https://github.com/dblock).
439
524
 
440
- ### 0.6.0 (9/16/2013)
525
+ ### 0.6.0 (2013/9/16)
441
526
 
442
527
  #### Features
443
528
 
@@ -455,7 +540,7 @@
455
540
 
456
541
  * [#428](https://github.com/ruby-grape/grape/issues/428): Removes memoization from `Grape::Request` params to prevent middleware from freezing parameter values before `Formatter` can get them - [@mbleigh](https://github.com/mbleigh).
457
542
 
458
- ### 0.5.0 (6/14/2013)
543
+ ### 0.5.0 (2013/6/14)
459
544
 
460
545
  #### Features
461
546
 
@@ -481,11 +566,11 @@
481
566
  * [#423](https://github.com/ruby-grape/grape/pull/423): Fix: `Grape::Endpoint#declared` now correctly handles nested params (ie. declared with `group`) - [@jbarreneche](https://github.com/jbarreneche).
482
567
  * [#427](https://github.com/ruby-grape/grape/issues/427): Fix: `declared(params)` breaks when `params` contains array - [@timhabermaas](https://github.com/timhabermaas).
483
568
 
484
- ### 0.4.1 (4/1/2013)
569
+ ### 0.4.1 (2013/4/1)
485
570
 
486
571
  * [#375](https://github.com/ruby-grape/grape/pull/375): Fix: throwing an `:error` inside a middleware doesn't respect the `format` settings - [@dblock](https://github.com/dblock).
487
572
 
488
- ### 0.4.0 (3/17/2013)
573
+ ### 0.4.0 (2013/3/17)
489
574
 
490
575
  * [#356](https://github.com/ruby-grape/grape/pull/356): Fix: presenting collections other than `Array` (eg. `ActiveRecord::Relation`) - [@zimbatm](https://github.com/zimbatm).
491
576
  * [#352](https://github.com/ruby-grape/grape/pull/352): Fix: using `Rack::JSONP` with `Grape::Entity` responses - [@deckchair](https://github.com/deckchair).
@@ -499,15 +584,15 @@
499
584
  * [#353](https://github.com/ruby-grape/grape/issues/353): Revert to standard Ruby logger formatter, `require active_support/all` if you want old behavior - [@rhunter](https://github.com/rhunter), [@dblock](https://github.com/dblock).
500
585
  * Fix: `undefined method 'call' for nil:NilClass` for an API method implementation without a block, now returns an empty string - [@dblock](https://github.com/dblock).
501
586
 
502
- ### 0.3.2 (2/28/2013)
587
+ ### 0.3.2 (2013/2/28)
503
588
 
504
589
  * [#355](https://github.com/ruby-grape/grape/issues/355): Relax dependency constraint on Hashie - [@reset](https://github.com/reset).
505
590
 
506
- ### 0.3.1 (2/25/2013)
591
+ ### 0.3.1 (2013/2/25)
507
592
 
508
593
  * [#351](https://github.com/ruby-grape/grape/issues/351): Compatibility with Ruby 2.0 - [@mbleigh](https://github.com/mbleigh).
509
594
 
510
- ### 0.3.0 (02/21/2013)
595
+ ### 0.3.0 (2013/02/21)
511
596
 
512
597
  * [#294](https://github.com/ruby-grape/grape/issues/294): Extracted `Grape::Entity` into a [grape-entity](https://github.com/agileanimal/grape-entity) gem - [@agileanimal](https://github.com/agileanimal).
513
598
  * [#340](https://github.com/ruby-grape/grape/pull/339), [#342](https://github.com/ruby-grape/grape/pull/342): Added `:cascade` option to `version` to allow disabling of rack/mount cascade behavior - [@dieb](https://github.com/dieb).
@@ -526,12 +611,12 @@
526
611
  * [#60](https://github.com/ruby-grape/grape/issues/60): Fix: mounting of a Grape API onto a path - [@dblock](https://github.com/dblock).
527
612
  * [#335](https://github.com/ruby-grape/grape/pull/335): Fix: request body parameters from a `PATCH` request not available in `params` - [@FreakenK](https://github.com/FreakenK).
528
613
 
529
- ### 0.2.6 (01/11/2013)
614
+ ### 0.2.6 (2013/01/11)
530
615
 
531
616
  * Fix: support content-type with character set when parsing POST and PUT input - [@dblock](https://github.com/dblock).
532
617
  * Fix: CVE-2013-0175, multi_xml parse vulnerability, require multi_xml 0.5.2 - [@dblock](https://github.com/dblock).
533
618
 
534
- ### 0.2.5 (01/10/2013)
619
+ ### 0.2.5 (2013/01/10)
535
620
 
536
621
  * Added support for custom parsers via `parser`, in addition to built-in multipart, JSON and XML parsers - [@dblock](https://github.com/dblock).
537
622
  * Removed `body_params`, data sent via a POST or PUT with a supported content-type is merged into `params` - [@dblock](https://github.com/dblock).
@@ -540,7 +625,7 @@
540
625
  * [#305](https://github.com/ruby-grape/grape/issues/305): Fix: presenting arrays of objects via `represent` or when auto-detecting an `Entity` constant in the objects being presented - [@brandonweiss](https://github.com/brandonweiss).
541
626
  * [#306](https://github.com/ruby-grape/grape/issues/306): Added i18n support for validation error messages - [@niedhui](https://github.com/niedhui).
542
627
 
543
- ### 0.2.4 (01/06/2013)
628
+ ### 0.2.4 (2013/01/06)
544
629
 
545
630
  * [#297](https://github.com/ruby-grape/grape/issues/297): Added `default_error_formatter` - [@dblock](https://github.com/dblock).
546
631
  * [#297](https://github.com/ruby-grape/grape/issues/297): Setting `format` will automatically set `default_error_formatter` - [@dblock](https://github.com/dblock).
@@ -558,7 +643,7 @@
558
643
  * [#304](https://github.com/ruby-grape/grape/issues/304): Fix: `present x, :with => Entity` returns class references with `format :json` - [@dblock](https://github.com/dblock).
559
644
  * [#196](https://github.com/ruby-grape/grape/issues/196): Fix: root requests don't work with `prefix` - [@dblock](https://github.com/dblock).
560
645
 
561
- ### 0.2.3 (24/12/2012)
646
+ ### 0.2.3 (2012/12/24)
562
647
 
563
648
  * [#179](https://github.com/ruby-grape/grape/issues/178): Using `content_type` will remove all default content-types - [@dblock](https://github.com/dblock).
564
649
  * [#265](https://github.com/ruby-grape/grape/issues/264): Fix: Moved `ValidationError` into `Grape::Exceptions` - [@thepumpkin1979](https://github.com/thepumpkin1979).
@@ -571,7 +656,7 @@
571
656
  * [#290](https://github.com/ruby-grape/grape/pull/290): The default error format for XML is now `error/message` instead of `hash/error` - [@dpsk](https://github.com/dpsk).
572
657
  * [#44](https://github.com/ruby-grape/grape/issues/44): Pass `env` into formatters to enable templating - [@dblock](https://github.com/dblock).
573
658
 
574
- ### 0.2.2 (12/10/2012)
659
+ ### 0.2.2 (2012/12/10)
575
660
 
576
661
  #### Features
577
662
 
@@ -593,7 +678,7 @@
593
678
  * [#208](https://github.com/ruby-grape/grape/pull/208): `Entity#serializable_hash` must also check if attribute is generated by a user supplied block - [@ppadron](https://github.com/ppadron).
594
679
  * [#252](https://github.com/ruby-grape/grape/pull/252): Resources that don't respond to a requested HTTP method return 405 (Method Not Allowed) instead of 404 (Not Found) - [@simulacre](https://github.com/simulacre).
595
680
 
596
- ### 0.2.1 (7/11/2012)
681
+ ### 0.2.1 (2012/7/11)
597
682
 
598
683
  * [#186](https://github.com/ruby-grape/grape/issues/186): Fix: helpers allow multiple calls with modules and blocks - [@ppadron](https://github.com/ppadron).
599
684
  * [#188](https://github.com/ruby-grape/grape/pull/188): Fix: multi-method routes append '(.:format)' only once - [@kainosnoema](https://github.com/kainosnoema).
@@ -608,7 +693,7 @@
608
693
  * [#189](https://github.com/ruby-grape/grape/pull/189): `HEAD` requests no longer return a body - [@stephencelis](https://github.com/stephencelis).
609
694
  * [#97](https://github.com/ruby-grape/grape/issues/97): Allow overriding `Content-Type` - [@dblock](https://github.com/dblock).
610
695
 
611
- ### 0.2.0 (3/28/2012)
696
+ ### 0.2.0 (2012/3/28)
612
697
 
613
698
  * Added support for inheriting exposures from entities - [@bobbytables](https://github.com/bobbytables).
614
699
  * Extended formatting with `default_format` - [@dblock](https://github.com/dblock).
@@ -628,28 +713,28 @@
628
713
  * Added support for before and after filters - [@mbleigh](https://github.com/mbleigh).
629
714
  * Extended `rescue_from`, which can now take a block - [@dblock](https://github.com/dblock).
630
715
 
631
- ### 0.1.5 (6/14/2011)
716
+ ### 0.1.5 (2011/6/14)
632
717
 
633
718
  * Extended exception handling to all exceptions - [@dblock](https://github.com/dblock).
634
719
  * Added support for returning JSON objects from within error blocks - [@dblock](https://github.com/dblock).
635
720
  * Added support for handling incoming JSON in body - [@tedkulp](https://github.com/tedkulp).
636
721
  * Added support for HTTP digest authentication - [@daddz](https://github.com/daddz).
637
722
 
638
- ### 0.1.4 (4/8/2011)
723
+ ### 0.1.4 (2011/4/8)
639
724
 
640
725
  * Allow multiple definitions of the same endpoint under multiple versions - [@chrisrhoden](https://github.com/chrisrhoden).
641
726
  * Added support for multipart URL parameters - [@mcastilho](https://github.com/mcastilho).
642
727
  * Added support for custom formatters - [@spraints](https://github.com/spraints).
643
728
 
644
- ### 0.1.3 (1/10/2011)
729
+ ### 0.1.3 (2011/1/10)
645
730
 
646
731
  * Added support for JSON format in route matching - [@aiwilliams](https://github.com/aiwilliams).
647
732
  * Added suport for custom middleware - [@mbleigh](https://github.com/mbleigh).
648
733
 
649
- ### 0.1.1 (11/14/2010)
734
+ ### 0.1.1 (2010/11/14)
650
735
 
651
736
  * Endpoints properly reset between each request - [@mbleigh](https://github.com/mbleigh).
652
737
 
653
- ### 0.1.0 (11/13/2010)
738
+ ### 0.1.0 (2010/11/13)
654
739
 
655
740
  * Initial public release - [@mbleigh](https://github.com/mbleigh).
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2018 Michael Bleigh, Intridea Inc. and Contributors.
1
+ Copyright (c) 2010-2019 Michael Bleigh, Intridea Inc. and Contributors.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -2,11 +2,9 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/grape.svg)](http://badge.fury.io/rb/grape)
4
4
  [![Build Status](https://travis-ci.org/ruby-grape/grape.svg?branch=master)](https://travis-ci.org/ruby-grape/grape)
5
- [![Dependency Status](https://gemnasium.com/ruby-grape/grape.svg)](https://gemnasium.com/ruby-grape/grape)
6
5
  [![Code Climate](https://codeclimate.com/github/ruby-grape/grape.svg)](https://codeclimate.com/github/ruby-grape/grape)
7
6
  [![Coverage Status](https://coveralls.io/repos/github/ruby-grape/grape/badge.svg?branch=master)](https://coveralls.io/github/ruby-grape/grape?branch=master)
8
- [![Inline docs](http://inch-ci.org/github/ruby-grape/grape.svg)](http://inch-ci.org/github/ruby-grape/grape)
9
- [![git.legal](https://git.legal/projects/1364/badge.svg "Number of libraries approved")](https://git.legal/projects/1364)
7
+ [![Inline docs](https://inch-ci.org/github/ruby-grape/grape.svg)](https://inch-ci.org/github/ruby-grape/grape)
10
8
  [![Join the chat at https://gitter.im/ruby-grape/grape](https://badges.gitter.im/ruby-grape/grape.svg)](https://gitter.im/ruby-grape/grape?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
11
9
 
12
10
  ## Table of Contents
@@ -17,17 +15,23 @@
17
15
  - [Installation](#installation)
18
16
  - [Basic Usage](#basic-usage)
19
17
  - [Mounting](#mounting)
18
+ - [All](#all)
20
19
  - [Rack](#rack)
21
20
  - [ActiveRecord without Rails](#activerecord-without-rails)
22
21
  - [Alongside Sinatra (or other frameworks)](#alongside-sinatra-or-other-frameworks)
23
22
  - [Rails](#rails)
23
+ - [Rails < 5.2](#rails--52)
24
+ - [Rails 6.0](#rails-60)
24
25
  - [Modules](#modules)
26
+ - [Remounting](#remounting)
27
+ - [Mount Configuration](#mount-configuration)
25
28
  - [Versioning](#versioning)
26
29
  - [Path](#path)
27
30
  - [Header](#header)
28
31
  - [Accept-Version Header](#accept-version-header)
29
32
  - [Param](#param)
30
33
  - [Describing Methods](#describing-methods)
34
+ - [Configuration](#configuration)
31
35
  - [Parameters](#parameters)
32
36
  - [Params Class](#params-class)
33
37
  - [Declared](#declared)
@@ -38,38 +42,43 @@
38
42
  - [Integer/Fixnum and Coercions](#integerfixnum-and-coercions)
39
43
  - [Custom Types and Coercions](#custom-types-and-coercions)
40
44
  - [Multipart File Parameters](#multipart-file-parameters)
41
- - [First-Class `JSON` Types](#first-class-json-types)
45
+ - [First-Class JSON Types](#first-class-json-types)
42
46
  - [Multiple Allowed Types](#multiple-allowed-types)
43
47
  - [Validation of Nested Parameters](#validation-of-nested-parameters)
44
48
  - [Dependent Parameters](#dependent-parameters)
45
49
  - [Group Options](#group-options)
46
- - [Alias](#alias)
50
+ - [Renaming](#renaming)
47
51
  - [Built-in Validators](#built-in-validators)
48
- - [`allow_blank`](#allow_blank)
49
- - [`values`](#values)
50
- - [`except_values`](#except_values)
51
- - [`regexp`](#regexp)
52
- - [`mutually_exclusive`](#mutually_exclusive)
53
- - [`exactly_one_of`](#exactly_one_of)
54
- - [`at_least_one_of`](#at_least_one_of)
55
- - [`all_or_none_of`](#all_or_none_of)
56
- - [Nested `mutually_exclusive`, `exactly_one_of`, `at_least_one_of`, `all_or_none_of`](#nested-mutually_exclusive-exactly_one_of-at_least_one_of-all_or_none_of)
52
+ - [allow_blank](#allow_blank)
53
+ - [values](#values)
54
+ - [except_values](#except_values)
55
+ - [same_as](#same_as)
56
+ - [regexp](#regexp)
57
+ - [mutually_exclusive](#mutually_exclusive)
58
+ - [exactly_one_of](#exactly_one_of)
59
+ - [at_least_one_of](#at_least_one_of)
60
+ - [all_or_none_of](#all_or_none_of)
61
+ - [Nested mutually_exclusive, exactly_one_of, at_least_one_of, all_or_none_of](#nested-mutually_exclusive-exactly_one_of-at_least_one_of-all_or_none_of)
57
62
  - [Namespace Validation and Coercion](#namespace-validation-and-coercion)
58
63
  - [Custom Validators](#custom-validators)
59
64
  - [Validation Errors](#validation-errors)
60
65
  - [I18n](#i18n)
61
66
  - [Custom Validation messages](#custom-validation-messages)
62
- - [`presence`, `allow_blank`, `values`, `regexp`](#presence-allow_blank-values-regexp)
63
- - [`all_or_none_of`](#all_or_none_of-1)
64
- - [`mutually_exclusive`](#mutually_exclusive-1)
65
- - [`exactly_one_of`](#exactly_one_of-1)
66
- - [`at_least_one_of`](#at_least_one_of-1)
67
- - [`Coerce`](#coerce)
68
- - [`With Lambdas`](#with-lambdas)
69
- - [`Pass symbols for i18n translations`](#pass-symbols-for-i18n-translations)
67
+ - [presence, allow_blank, values, regexp](#presence-allow_blank-values-regexp)
68
+ - [same_as](#same_as-1)
69
+ - [all_or_none_of](#all_or_none_of-1)
70
+ - [mutually_exclusive](#mutually_exclusive-1)
71
+ - [exactly_one_of](#exactly_one_of-1)
72
+ - [at_least_one_of](#at_least_one_of-1)
73
+ - [Coerce](#coerce)
74
+ - [With Lambdas](#with-lambdas)
75
+ - [Pass symbols for i18n translations](#pass-symbols-for-i18n-translations)
70
76
  - [Overriding Attribute Names](#overriding-attribute-names)
71
77
  - [With Default](#with-default)
72
78
  - [Headers](#headers)
79
+ - [Request](#request)
80
+ - [Header Case Handling](#header-case-handling)
81
+ - [Response](#response)
73
82
  - [Routes](#routes)
74
83
  - [Helpers](#helpers)
75
84
  - [Path Helpers](#path-helpers)
@@ -105,7 +114,7 @@
105
114
  - [Register custom middleware for authentication](#register-custom-middleware-for-authentication)
106
115
  - [Describing and Inspecting an API](#describing-and-inspecting-an-api)
107
116
  - [Current Route and Endpoint](#current-route-and-endpoint)
108
- - [Before and After](#before-and-after)
117
+ - [Before, After and Finally](#before-after-and-finally)
109
118
  - [Anchoring](#anchoring)
110
119
  - [Using Custom Middleware](#using-custom-middleware)
111
120
  - [Grape Middleware](#grape-middleware)
@@ -145,7 +154,7 @@ content negotiation, versioning and much more.
145
154
 
146
155
  ## Stable Release
147
156
 
148
- You're reading the documentation for the stable release of Grape, **1.1.0**.
157
+ You're reading the documentation for the stable release of Grape, **1.2.5**.
149
158
  Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
150
159
 
151
160
  ## Project Resources
@@ -204,7 +213,7 @@ module Twitter
204
213
 
205
214
  desc 'Return a status.'
206
215
  params do
207
- requires :id, type: Integer, desc: 'Status id.'
216
+ requires :id, type: Integer, desc: 'Status ID.'
208
217
  end
209
218
  route_param :id do
210
219
  get do
@@ -252,6 +261,17 @@ end
252
261
 
253
262
  ## Mounting
254
263
 
264
+ ### All
265
+
266
+
267
+ By default Grape will compile the routes on the first route, it is possible to pre-load routes using the `compile!` method.
268
+
269
+ ```ruby
270
+ Twitter::API.compile!
271
+ ```
272
+
273
+ This can be added to your `config.ru` (if using rackup), `application.rb` (if using rails), or any file that loads your server.
274
+
255
275
  ### Rack
256
276
 
257
277
  The above sample creates a Rack application that can be run from a rackup `config.ru` file
@@ -261,6 +281,13 @@ with `rackup`:
261
281
  run Twitter::API
262
282
  ```
263
283
 
284
+ (With pre-loading you can use)
285
+
286
+ ```ruby
287
+ Twitter::API.compile!
288
+ run Twitter::API
289
+ ```
290
+
264
291
  And would respond to the following routes:
265
292
 
266
293
  GET /api/statuses/public_timeline
@@ -317,6 +344,14 @@ run Rack::Cascade.new [API, Web]
317
344
 
318
345
  Place API files into `app/api`. Rails expects a subdirectory that matches the name of the Ruby module and a file name that matches the name of the class. In our example, the file name location and directory for `Twitter::API` should be `app/api/twitter/api.rb`.
319
346
 
347
+ Modify `config/routes`:
348
+
349
+ ```ruby
350
+ mount Twitter::API => '/'
351
+ ```
352
+
353
+ #### Rails < 5.2
354
+
320
355
  Modify `application.rb`:
321
356
 
322
357
  ```ruby
@@ -324,14 +359,18 @@ config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
324
359
  config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
325
360
  ```
326
361
 
327
- Modify `config/routes`:
362
+ See [below](#reloading-api-changes-in-development) for additional code that enables reloading of API changes in development.
363
+
364
+ #### Rails 6.0
365
+
366
+ For Rails versions greater than 6.0.0.beta2, `Zeitwerk` autoloader is the default for CRuby. By default `Zeitwerk` inflects `api` as `Api` instead of `API`. To make our example work, you need to uncomment the lines at the bottom of `config/initializers/inflections.rb`, and add `API` as an acronym:
328
367
 
329
368
  ```ruby
330
- mount Twitter::API => '/'
369
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
370
+ inflect.acronym 'API'
371
+ end
331
372
  ```
332
373
 
333
- See [below](#reloading-api-changes-in-development) for additional code that enables reloading of API changes in development.
334
-
335
374
  ### Modules
336
375
 
337
376
  You can mount multiple API implementations inside another one. These don't have to be
@@ -365,6 +404,131 @@ class Twitter::API < Grape::API
365
404
  end
366
405
  ```
367
406
 
407
+ ## Remounting
408
+
409
+ You can mount the same endpoints in two different locations.
410
+
411
+ ```ruby
412
+ class Voting::API < Grape::API
413
+ namespace 'votes' do
414
+ get do
415
+ # Your logic
416
+ end
417
+
418
+ post do
419
+ # Your logic
420
+ end
421
+ end
422
+ end
423
+
424
+ class Post::API < Grape::API
425
+ mount Voting::API
426
+ end
427
+
428
+ class Comment::API < Grape::API
429
+ mount Voting::API
430
+ end
431
+ ```
432
+
433
+ Assuming that the post and comment endpoints are mounted in `/posts` and `/comments`, you should now be able to do `get /posts/votes`, `post /posts/votes`, `get /comments/votes` and `post /comments/votes`.
434
+
435
+ ### Mount Configuration
436
+
437
+ You can configure remountable endpoints to change how they behave according to where they are mounted.
438
+
439
+ ```ruby
440
+ class Voting::API < Grape::API
441
+ namespace 'votes' do
442
+ desc "Vote for your #{configuration[:votable]}"
443
+ get do
444
+ # Your logic
445
+ end
446
+ end
447
+ end
448
+
449
+ class Post::API < Grape::API
450
+ mount Voting::API, with: { votable: 'posts' }
451
+ end
452
+
453
+ class Comment::API < Grape::API
454
+ mount Voting::API, with: { votable: 'comments' }
455
+ end
456
+ ```
457
+
458
+ Note that if you're passing a hash as the first parameter to `mount`, you will need to explicitly put `()` around parameters:
459
+ ```ruby
460
+ # good
461
+ mount({ ::Some::Api => '/some/api' }, with: { condition: true })
462
+
463
+ # bad
464
+ mount ::Some::Api => '/some/api', with: { condition: true }
465
+ ```
466
+
467
+ You can access `configuration` on the class (to use as dynamic attributes), inside blocks (like namespace)
468
+
469
+ If you want logic happening given on an `configuration`, you can use the helper `given`.
470
+
471
+ ```ruby
472
+ class ConditionalEndpoint::API < Grape::API
473
+ given configuration[:some_setting] do
474
+ get 'mount_this_endpoint_conditionally' do
475
+ configuration[:configurable_response]
476
+ end
477
+ end
478
+ end
479
+ ```
480
+
481
+ If you want a block of logic running every time an endpoint is mounted (within which you can access the `configuration` Hash)
482
+
483
+
484
+ ```ruby
485
+ class ConditionalEndpoint::API < Grape::API
486
+ mounted do
487
+ YourLogger.info "This API was mounted at: #{Time.now}"
488
+
489
+ get configuration[:endpoint_name] do
490
+ configuration[:configurable_response]
491
+ end
492
+ end
493
+ end
494
+ ```
495
+
496
+ More complex results can be achieved by using `mounted` as an expression within which the `configuration` is already evaluated as a Hash.
497
+
498
+ ```ruby
499
+ class ExpressionEndpointAPI < Grape::API
500
+ get(mounted { configuration[:route_name] || 'default_name' }) do
501
+ # some logic
502
+ end
503
+ end
504
+ ```
505
+
506
+ ```ruby
507
+ class BasicAPI < Grape::API
508
+ desc 'Statuses index' do
509
+ params: mounted { configuration[:entity] || API::Entities::Status }.documentation
510
+ end
511
+ params do
512
+ requires :all, using: mounted { configuration[:entity] || API::Entities::Status }.documentation
513
+ end
514
+ get '/statuses' do
515
+ statuses = Status.all
516
+ type = current_user.admin? ? :full : :default
517
+ present statuses, with: mounted { configuration[:entity] || API::Entities::Status }, type: type
518
+ end
519
+ end
520
+
521
+ class V1 < Grape::API
522
+ version 'v1'
523
+ mount BasicAPI, with: { entity: mounted { configuration[:entity] || API::Enitities::Status } }
524
+ end
525
+
526
+ class V2 < Grape::API
527
+ version 'v2'
528
+ mount BasicAPI, with: { entity: mounted { configuration[:entity] || API::Enitities::V2::Status } }
529
+ end
530
+ ```
531
+
368
532
  ## Versioning
369
533
 
370
534
  There are four strategies in which clients can reach your API's endpoints: `:path`,
@@ -445,10 +609,13 @@ version 'v1', using: :param, parameter: 'v'
445
609
 
446
610
  ## Describing Methods
447
611
 
448
- You can add a description to API methods and namespaces.
612
+ You can add a description to API methods and namespaces. The description would be used by [grape-swagger][grape-swagger] to generate swagger compliant documentation.
613
+
614
+ Note: Description block is only for documentation and won't affects API behavior.
449
615
 
450
616
  ```ruby
451
617
  desc 'Returns your public timeline.' do
618
+ summary 'summary'
452
619
  detail 'more details'
453
620
  params API::Entities::Status.documentation
454
621
  success API::Entities::Entity
@@ -462,7 +629,13 @@ desc 'Returns your public timeline.' do
462
629
  description: 'Not really needed',
463
630
  required: false
464
631
  }
465
-
632
+ hidden false
633
+ deprecated false
634
+ is_array true
635
+ nickname 'nickname'
636
+ produces ['application/json']
637
+ consumes ['application/json']
638
+ tags ['tag1', 'tag2']
466
639
  end
467
640
  get :public_timeline do
468
641
  Status.limit(20)
@@ -475,6 +648,43 @@ end
475
648
  * `failure`: (former http_codes) A definition of the used failure HTTP Codes and Entities
476
649
  * `named`: A helper to give a route a name and find it with this name in the documentation Hash
477
650
  * `headers`: A definition of the used Headers
651
+ * Other options can be found in [grape-swagger][grape-swagger]
652
+
653
+ [grape-swagger]: https://github.com/ruby-grape/grape-swagger
654
+
655
+ ## Configuration
656
+
657
+ Use `Grape.configure` to set up global settings at load time.
658
+ Currently the configurable settings are:
659
+
660
+ * `param_builder`: Sets the [Parameter Builder](#parameters), defaults to `Grape::Extensions::ActiveSupport::HashWithIndifferentAccess::ParamBuilder`.
661
+
662
+ To change a setting value make sure that at some point during load time the following code runs
663
+
664
+ ```ruby
665
+ Grape.configure do |config|
666
+ config.setting = value
667
+ end
668
+ ```
669
+
670
+ For example, for the `param_builder`, the following code could run in an initializer:
671
+
672
+ ```ruby
673
+ Grape.configure do |config|
674
+ config.param_builder = Grape::Extensions::Hashie::Mash::ParamBuilder
675
+ end
676
+ ```
677
+
678
+ You can also configure a single API:
679
+
680
+ ```ruby
681
+ API.configure do |config|
682
+ config[key] = value
683
+ end
684
+ ```
685
+
686
+ This will be available inside the API with `configuration`, as if it were
687
+ [mount configuration](#mount-configuration).
478
688
 
479
689
  ## Parameters
480
690
 
@@ -553,6 +763,8 @@ params do
553
763
  end
554
764
  ```
555
765
 
766
+ Or globally with the [Configuration](#configuration) `Grape.configure.param_builder`.
767
+
556
768
  In the example above, `params["color"]` will return `nil` since `params` is a plain `Hash`.
557
769
 
558
770
  Available parameter builders are `Grape::Extensions::Hash::ParamBuilder`, `Grape::Extensions::ActiveSupport::HashWithIndifferentAccess::ParamBuilder` and `Grape::Extensions::Hashie::Mash::ParamBuilder`.
@@ -934,7 +1146,7 @@ parameter, and the return value must match the given `type`.
934
1146
 
935
1147
  ```ruby
936
1148
  params do
937
- requires :passwd, type: String, coerce_with: Base64.method(:decode)
1149
+ requires :passwd, type: String, coerce_with: Base64.method(:decode64)
938
1150
  requires :loud_color, type: Color, coerce_with: ->(c) { Color.parse(c.downcase) }
939
1151
 
940
1152
  requires :obj, type: Hash, coerce_with: JSON do
@@ -1109,6 +1321,18 @@ params do
1109
1321
  end
1110
1322
  ```
1111
1323
 
1324
+ You can rename parameters:
1325
+
1326
+ ```ruby
1327
+ params do
1328
+ optional :category, as: :type
1329
+ given type: ->(val) { val == 'foo' } do
1330
+ requires :description
1331
+ end
1332
+ end
1333
+ ```
1334
+
1335
+ Note: param in `given` should be the renamed one. In the example, it should be `type`, not `category`.
1112
1336
 
1113
1337
  ### Group Options
1114
1338
 
@@ -1137,9 +1361,9 @@ params do
1137
1361
  end
1138
1362
  ```
1139
1363
 
1140
- ### Alias
1364
+ ### Renaming
1141
1365
 
1142
- You can set an alias for parameters using `as`, which can be useful when refactoring existing APIs:
1366
+ You can rename parameters using `as`, which can be useful when refactoring existing APIs:
1143
1367
 
1144
1368
  ```ruby
1145
1369
  resource :users do
@@ -1248,6 +1472,17 @@ params do
1248
1472
  end
1249
1473
  ```
1250
1474
 
1475
+ #### `same_as`
1476
+
1477
+ A `same_as` option can be given to ensure that values of parameters match.
1478
+
1479
+ ```ruby
1480
+ params do
1481
+ requires :password
1482
+ requires :password_confirmation, same_as: :password
1483
+ end
1484
+ ```
1485
+
1251
1486
  #### `regexp`
1252
1487
 
1253
1488
  Parameters can be restricted to match a specific regular expression with the `:regexp` option. If the value
@@ -1546,6 +1781,8 @@ end
1546
1781
  Grape supports I18n for parameter-related error messages, but will fallback to English if
1547
1782
  translations for the default locale have not been provided. See [en.yml](lib/grape/locale/en.yml) for message keys.
1548
1783
 
1784
+ In case your app enforces available locales only and :en is not included in your available locales, Grape cannot fall back to English and will return the translation key for the error message. To avoid this behaviour, either provide a translation for your default locale or add :en to your available locales.
1785
+
1549
1786
  ### Custom Validation messages
1550
1787
 
1551
1788
  Grape supports custom validation messages for parameter-related and coerce-related error messages.
@@ -1558,6 +1795,15 @@ params do
1558
1795
  end
1559
1796
  ```
1560
1797
 
1798
+ #### `same_as`
1799
+
1800
+ ```ruby
1801
+ params do
1802
+ requires :password
1803
+ requires :password_confirmation, same_as: { value: :password, message: 'not match' }
1804
+ end
1805
+ ```
1806
+
1561
1807
  #### `all_or_none_of`
1562
1808
 
1563
1809
  ```ruby
@@ -1587,7 +1833,7 @@ params do
1587
1833
  optional :beer
1588
1834
  optional :wine
1589
1835
  optional :juice
1590
- exactly_one_of :beer, :wine, :juice, message: {exactly_one: "are missing, exactly one parameter is required", mutual_exclusion: "are mutually exclusive, exactly one parameter is required"}
1836
+ exactly_one_of :beer, :wine, :juice, message: { exactly_one: "are missing, exactly one parameter is required", mutual_exclusion: "are mutually exclusive, exactly one parameter is required" }
1591
1837
  end
1592
1838
  ```
1593
1839
 
@@ -1606,7 +1852,7 @@ end
1606
1852
 
1607
1853
  ```ruby
1608
1854
  params do
1609
- requires :int, type: {value: Integer, message: "type cast is invalid" }
1855
+ requires :int, type: { value: Integer, message: "type cast is invalid" }
1610
1856
  end
1611
1857
  ```
1612
1858
 
@@ -1668,6 +1914,7 @@ end
1668
1914
 
1669
1915
  ## Headers
1670
1916
 
1917
+ ### Request
1671
1918
  Request headers are available through the `headers` helper or from `env` in their original form.
1672
1919
 
1673
1920
  ```ruby
@@ -1682,13 +1929,30 @@ get do
1682
1929
  end
1683
1930
  ```
1684
1931
 
1932
+ #### Header Case Handling
1933
+
1934
+ The above example may have been requested as follows:
1935
+
1936
+ ``` shell
1937
+ curl -H "secret_PassWord: swordfish" ...
1938
+ ```
1939
+
1940
+ The header name will have been normalized for you.
1941
+
1942
+ - In the `header` helper names will be coerced into a capitalized kebab case.
1943
+ - In the `env` collection they appear in all uppercase, in snake case, and prefixed with 'HTTP_'.
1944
+
1945
+ The header name will have been normalized per HTTP standards defined in [RFC2616 Section 4.2](https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2) regardless of what is being sent by a client.
1946
+
1947
+ ### Response
1948
+
1685
1949
  You can set a response header with `header` inside an API.
1686
1950
 
1687
1951
  ```ruby
1688
1952
  header 'X-Robots-Tag', 'noindex'
1689
1953
  ```
1690
1954
 
1691
- When raising `error!`, pass additional headers as arguments.
1955
+ When raising `error!`, pass additional headers as arguments. Additional headers will be merged with headers set before `error!` call.
1692
1956
 
1693
1957
  ```ruby
1694
1958
  error! 'Unauthorized', 401, 'X-Error-Detail' => 'Invalid token.'
@@ -1696,6 +1960,56 @@ error! 'Unauthorized', 401, 'X-Error-Detail' => 'Invalid token.'
1696
1960
 
1697
1961
  ## Routes
1698
1962
 
1963
+ To define routes you can use the `route` method or the shorthands for the HTTP verbs. To define a route that accepts any route set to `:any`.
1964
+ Parts of the path that are denoted with a colon will be interpreted as route parameters.
1965
+
1966
+ ```ruby
1967
+ route :get, 'status' do
1968
+ end
1969
+
1970
+ # is the same as
1971
+
1972
+ get 'status' do
1973
+ end
1974
+
1975
+ # is the same as
1976
+
1977
+ get :status do
1978
+ end
1979
+
1980
+ # is NOT the same as
1981
+
1982
+ get ':status' do # this makes param[:status] available
1983
+ end
1984
+
1985
+ # This will make both param[:status_id] and param[:id] available
1986
+
1987
+ get 'statuses/:status_id/reviews/:id' do
1988
+ end
1989
+ ```
1990
+
1991
+ To declare a namespace that prefixes all routes within, use the `namespace` method. `group`, `resource`, `resources` and `segment` are aliases to this method. Any endpoints within will share their parent context as well as any configuration done in the namespace context.
1992
+
1993
+ The `route_param` method is a convenient method for defining a parameter route segment. If you define a type, it will add a validation for this parameter.
1994
+
1995
+ ```ruby
1996
+ route_param :id, type: Integer do
1997
+ get 'status' do
1998
+ end
1999
+ end
2000
+
2001
+ # is the same as
2002
+
2003
+ namespace ':id' do
2004
+ params do
2005
+ requires :id, type: Integer
2006
+ end
2007
+
2008
+ get 'status' do
2009
+ end
2010
+ end
2011
+ ```
2012
+
1699
2013
  Optionally, you can define requirements for your named route parameters using regular
1700
2014
  expressions on namespace or endpoint. The route will match only if all requirements are met.
1701
2015
 
@@ -2028,6 +2342,12 @@ instead of a message.
2028
2342
  error!({ error: 'unexpected error', detail: 'missing widget' }, 500)
2029
2343
  ```
2030
2344
 
2345
+ You can set additional headers for the response. They will be merged with headers set before `error!` call.
2346
+
2347
+ ```ruby
2348
+ error!('Something went wrong', 500, 'X-Error-Detail' => 'Invalid token.')
2349
+ ```
2350
+
2031
2351
  You can present documented errors with a Grape entity using the the [grape-entity](https://github.com/ruby-grape/grape-entity) gem.
2032
2352
 
2033
2353
  ```ruby
@@ -2182,7 +2502,7 @@ You can also rescue all exceptions with a code block and handle the Rack respons
2182
2502
  ```ruby
2183
2503
  class Twitter::API < Grape::API
2184
2504
  rescue_from :all do |e|
2185
- Rack::Response.new([ e.message ], 500, { 'Content-type' => 'text/error' }).finish
2505
+ Rack::Response.new([ e.message ], 500, { 'Content-type' => 'text/error' })
2186
2506
  end
2187
2507
  end
2188
2508
  ```
@@ -2253,9 +2573,9 @@ class Twitter::API < Grape::API
2253
2573
  end
2254
2574
  ```
2255
2575
 
2256
- The `rescue_from` block must return a `Rack::Response` object, call `error!` or re-raise an exception.
2576
+ The `rescue_from` handler must return a `Rack::Response` object, call `error!`, or raise an exception (either the original exception or another custom one). The exception raised in `rescue_from` will be handled outside Grape. For example, if you mount Grape in Rails, the exception will be handle by [Rails Action Controller](https://guides.rubyonrails.org/action_controller_overview.html#rescue).
2257
2577
 
2258
- The `with` keyword is available as `rescue_from` options, it can be passed method name or Proc object.
2578
+ Alternately, use the `with` option in `rescue_from` to specify a method or a `proc`.
2259
2579
 
2260
2580
  ```ruby
2261
2581
  class Twitter::API < Grape::API
@@ -2271,6 +2591,17 @@ class Twitter::API < Grape::API
2271
2591
  end
2272
2592
  ```
2273
2593
 
2594
+ Inside the `rescue_from` block, the environment of the original controller method(`.self` receiver) is accessible through the `#context` method.
2595
+
2596
+ ```ruby
2597
+ class Twitter::API < Grape::API
2598
+ rescue_from :all do |e|
2599
+ user_id = context.params[:user_id]
2600
+ error!("error for #{user_id}")
2601
+ end
2602
+ end
2603
+ ```
2604
+
2274
2605
  #### Rescuing exceptions inside namespaces
2275
2606
 
2276
2607
  You could put `rescue_from` clauses inside a namespace and they will take precedence over ones
@@ -2293,7 +2624,7 @@ class Twitter::API < Grape::API
2293
2624
  end
2294
2625
  ```
2295
2626
 
2296
- Here `'inner'` will be result of handling occured `ArgumentError`.
2627
+ Here `'inner'` will be result of handling occurred `ArgumentError`.
2297
2628
 
2298
2629
  #### Unrescuable Exceptions
2299
2630
 
@@ -2893,7 +3224,9 @@ end
2893
3224
 
2894
3225
  ```
2895
3226
 
2896
- Use [warden-oauth2](https://github.com/opperator/warden-oauth2) or [rack-oauth2](https://github.com/nov/rack-oauth2) for OAuth2 support.
3227
+ Use [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper), [warden-oauth2](https://github.com/opperator/warden-oauth2) or [rack-oauth2](https://github.com/nov/rack-oauth2) for OAuth2 support.
3228
+
3229
+ You can access the controller params, headers, and helpers through the context with the `#context` method inside any auth middleware inherited from `Grape::Middlware::Auth::Base`.
2897
3230
 
2898
3231
  ## Describing and Inspecting an API
2899
3232
 
@@ -2962,19 +3295,22 @@ class ApiLogger < Grape::Middleware::Base
2962
3295
  end
2963
3296
  ```
2964
3297
 
2965
- ## Before and After
3298
+ ## Before, After and Finally
2966
3299
 
2967
3300
  Blocks can be executed before or after every API call, using `before`, `after`,
2968
3301
  `before_validation` and `after_validation`.
3302
+ If the API fails the `after` call will not be trigered, if you need code to execute for sure
3303
+ use the `finally`.
2969
3304
 
2970
3305
  Before and after callbacks execute in the following order:
2971
3306
 
2972
3307
  1. `before`
2973
3308
  2. `before_validation`
2974
3309
  3. _validations_
2975
- 4. `after_validation`
2976
- 5. _the API call_
2977
- 6. `after`
3310
+ 4. `after_validation` (upon successful validation)
3311
+ 5. _the API call_ (upon successful validation)
3312
+ 6. `after` (upon successful validation and API call)
3313
+ 7. `finally` (always)
2978
3314
 
2979
3315
  Steps 4, 5 and 6 only happen if validation succeeds.
2980
3316
 
@@ -2994,6 +3330,14 @@ before do
2994
3330
  end
2995
3331
  ```
2996
3332
 
3333
+ You can ensure a block of code runs after every request (including failures) with `finally`:
3334
+
3335
+ ```ruby
3336
+ finally do
3337
+ # this code will run after every request (successful or failed)
3338
+ end
3339
+ ```
3340
+
2997
3341
  **Namespaces**
2998
3342
 
2999
3343
  Callbacks apply to each API call within and below the current namespace:
@@ -3196,6 +3540,8 @@ class API < Grape::API
3196
3540
  end
3197
3541
  ```
3198
3542
 
3543
+ You can access the controller params, headers, and helpers through the context with the `#context` method inside any middleware inherited from `Grape::Middlware::Base`.
3544
+
3199
3545
  ### Rails Middleware
3200
3546
 
3201
3547
  Note that when you're using Grape mounted on Rails you don't have to use Rails middleware because it's already included into your middleware stack.
@@ -3504,6 +3850,7 @@ Grape integrates with following third-party tools:
3504
3850
  * **Librato Metrics** - [grape-librato](https://github.com/seanmoon/grape-librato) gem
3505
3851
  * **[Skylight](https://www.skylight.io/)** - [skylight](https://github.com/skylightio/skylight-ruby) gem, [documentation](https://docs.skylight.io/grape/)
3506
3852
  * **[AppSignal](https://www.appsignal.com)** - [appsignal-ruby](https://github.com/appsignal/appsignal-ruby) gem, [documentation](http://docs.appsignal.com/getting-started/supported-frameworks.html#grape)
3853
+ * **[ElasticAPM](https://www.elastic.co/products/apm) - [elastic-apm](https://github.com/elastic/apm-agent-ruby) gem, [documentation](https://www.elastic.co/guide/en/apm/agent/ruby/3.x/getting-started-rack.html#getting-started-grape)
3507
3854
 
3508
3855
  ## Contributing to Grape
3509
3856
 
@@ -3518,4 +3865,4 @@ MIT License. See LICENSE for details.
3518
3865
 
3519
3866
  ## Copyright
3520
3867
 
3521
- Copyright (c) 2010-2018 Michael Bleigh, Intridea Inc. and Contributors.
3868
+ Copyright (c) 2010-2019 Michael Bleigh, Intridea Inc. and Contributors.