hanami-controller 2.0.0.alpha5 → 2.0.0.beta1
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/CHANGELOG.md +136 -3
- data/README.md +3 -5
- data/hanami-controller.gemspec +22 -20
- data/lib/hanami/action/base_params.rb +20 -57
- data/lib/hanami/action/cache/cache_control.rb +14 -10
- data/lib/hanami/action/cache/conditional_get.rb +8 -26
- data/lib/hanami/action/cache/directives.rb +8 -6
- data/lib/hanami/action/cache/expires.rb +10 -11
- data/lib/hanami/action/cache.rb +5 -3
- data/lib/hanami/action/configuration.rb +20 -12
- data/lib/hanami/action/constants.rb +261 -0
- data/lib/hanami/action/cookie_jar.rb +37 -55
- data/lib/hanami/action/cookies.rb +2 -0
- data/lib/hanami/action/csrf_protection.rb +28 -31
- data/lib/hanami/action/flash.rb +4 -0
- data/lib/hanami/action/halt.rb +4 -0
- data/lib/hanami/action/mime.rb +103 -73
- data/lib/hanami/action/params.rb +41 -31
- data/lib/hanami/action/rack/file.rb +5 -9
- data/lib/hanami/action/request.rb +10 -59
- data/lib/hanami/action/response.rb +89 -46
- data/lib/hanami/action/session.rb +5 -3
- data/lib/hanami/action/validatable.rb +18 -19
- data/lib/hanami/action/view_name_inferrer.rb +10 -0
- data/lib/hanami/action.rb +554 -98
- data/lib/hanami/controller/error.rb +2 -0
- data/lib/hanami/controller/version.rb +3 -1
- data/lib/hanami/controller.rb +10 -12
- data/lib/hanami/http/status.rb +4 -18
- metadata +25 -16
- data/lib/hanami/action/application_action.rb +0 -131
- data/lib/hanami/action/application_configuration/content_security_policy.rb +0 -118
- data/lib/hanami/action/application_configuration/cookies.rb +0 -29
- data/lib/hanami/action/application_configuration/sessions.rb +0 -46
- data/lib/hanami/action/application_configuration.rb +0 -90
- data/lib/hanami/action/glue.rb +0 -40
- data/lib/hanami/action/standalone_action.rb +0 -578
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11f51222319fd677dad5bcad139e3a9fe4ec4a9099a44cab8e1809de78ca7def
|
|
4
|
+
data.tar.gz: 38367d9e9a0831e0bae832ffc4a7528ba97ecafb399b57e085d723de522f0219
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5522815b014bd6bf4ad6750a12c80a6db7d1aaab15562004a7898bc6cf5a5f0bbfa93d171cee31268685268ead3d37d6aa42be1bfc780c7a3bba2207814df087
|
|
7
|
+
data.tar.gz: 379911174cd6deb4637e6dcb80731d1d221f6bb4f3c184001f6f526e8d87cdf385aa0e114a1c4fa78c2dc3361015074b5afbe428a2b630a8ff4cd17f180e5908
|
data/CHANGELOG.md
CHANGED
|
@@ -1,26 +1,62 @@
|
|
|
1
1
|
# Hanami::Controller
|
|
2
|
+
|
|
2
3
|
Complete, fast and testable actions for Rack
|
|
3
4
|
|
|
5
|
+
## v2.0.0.beta1 - 2022-07-20
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- [Benjamin Klotz] Using `Hanami::Action.params` without having `hanami-validations` installed now returns a user-friendly error
|
|
10
|
+
- [Narinda Reeders] Ensure HEAD responses to send empty body, but preserve headers
|
|
11
|
+
- [Narinda Reeders] Ensure HEAD redirect responses to return redirect headers
|
|
12
|
+
- [Andrew Croome] Do not automatically render halted requests
|
|
13
|
+
|
|
14
|
+
## v2.0.0.alpha8 - 2022-02-19
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- [Tim Riley] Removed automatic integration of `Hanami::Action` subclasses with their surrounding Hanami application. Action base classes within Hanami apps should inherit from `Hanami::Application::Action` instead.
|
|
19
|
+
|
|
20
|
+
## v2.0.0.alpha6 - 2022-02-10
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- [Luca Guidi] Official support for Ruby: MRI 3.1
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- [Luca Guidi] Drop support for Ruby: MRI 2.6, and 2.7.
|
|
29
|
+
- [Sean Collins] Align with Rack list of HTTP supported status. Added: `103`, `306`, `421`, `425`, `451`, and `509`. Removed: `418`, `420`, `444`, `449`, `450`, `451`, `499`, `598`, `599`.
|
|
30
|
+
|
|
4
31
|
## v2.0.0.alpha5 - 2022-01-12
|
|
32
|
+
|
|
5
33
|
### Added
|
|
34
|
+
|
|
6
35
|
- [Philip Arndt] Added "rss" ("application/rss+xml") to list of supported MIME types
|
|
7
36
|
|
|
8
37
|
## v2.0.0.alpha4 - 2021-12-07
|
|
38
|
+
|
|
9
39
|
### Added
|
|
40
|
+
|
|
10
41
|
- [Luca Guidi] Manage Content Security Policy (CSP) defaults and new API via `Hanami::Action::ApplicationConfiguration#content_security_policy`
|
|
11
42
|
- [Tim Riley & Marc Busqué] Provide access to routes inside all application actions via `Hanami::Action::ApplicationAction#routes`
|
|
12
43
|
|
|
13
44
|
## v2.0.0.alpha3 - 2021-11-09
|
|
45
|
+
|
|
14
46
|
### Added
|
|
47
|
+
|
|
15
48
|
- [Luca Guidi] Automatically include session behavior in `Hanami::Action` when sessions are enabled via Hanami application config
|
|
16
49
|
- [Sean Collins] Pass exposures from action to view
|
|
17
50
|
|
|
18
51
|
### Changed
|
|
52
|
+
|
|
19
53
|
- [Tim Riley] (Internal) Updated settings to use updated `setting` API in dry-configurable 0.13.0
|
|
20
54
|
- [Sean Collins] Move automatic view rendering from `handle` to `finish`
|
|
21
55
|
|
|
22
56
|
## v2.0.0.alpha2 - 2021-05-04
|
|
57
|
+
|
|
23
58
|
### Added
|
|
59
|
+
|
|
24
60
|
- [Luca Guidi] Official support for Ruby: MRI 3.0
|
|
25
61
|
- [Tim Riley] Introduced `Hanami::Action::ApplicationAction`
|
|
26
62
|
- [Tim Riley] Introduced `Hanami::Action::Configuration`
|
|
@@ -30,21 +66,26 @@ Complete, fast and testable actions for Rack
|
|
|
30
66
|
- [Tim Riley] Enable CSRF protection automatically when HTTP sessions are enabled
|
|
31
67
|
|
|
32
68
|
### Fixed
|
|
69
|
+
|
|
33
70
|
- [Luca Guidi] Ensure `Hanami::Action::Response#renderable?` to return `false` when body is set
|
|
34
71
|
- [Andrew Croome] Ensure `Hanami::Action.accept` to use Rack `CONTENT_TYPE` for the _before callback_ check
|
|
35
72
|
|
|
36
73
|
### Changed
|
|
74
|
+
|
|
37
75
|
- [Luca Guidi] Drop support for Ruby: MRI 2.5.
|
|
38
76
|
- [Tim Riley] Removed `Hanami::Action.handle_exception` in favor of `Hanami::Action.config.handle_exception`
|
|
39
77
|
- [Tim Riley] Rewritten `Hanami::Action::Flash`, based on Roda's `FlashHash`
|
|
40
78
|
|
|
41
79
|
## v2.0.0.alpha1 - 2019-01-30
|
|
80
|
+
|
|
42
81
|
### Added
|
|
82
|
+
|
|
43
83
|
- [Luca Guidi] `Hanami::Action::Request#session` to access the HTTP session as it was originally sent
|
|
44
84
|
- [Luca Guidi] `Hanami::Action::Request#cookies` to access the HTTP cookies as they were originally sent
|
|
45
85
|
- [Luca Guidi & Tim Riley] Allow to build a deep inheritance chain for actions
|
|
46
86
|
|
|
47
87
|
### Changed
|
|
88
|
+
|
|
48
89
|
- [Luca Guidi] Drop support for Ruby: MRI 2.3, and 2.4.
|
|
49
90
|
- [Luca Guidi] `Hanami::Action` is a superclass
|
|
50
91
|
- [Luca Guidi] `Hanami::Action#initialize` requires a `configuration:` keyword argument
|
|
@@ -88,40 +129,54 @@ Complete, fast and testable actions for Rack
|
|
|
88
129
|
- [Luca Guidi] `Hanami::Action` exception handlers now accept `Hanami::Action::Request`, `Hanami::Action::Response`, and exception arguments
|
|
89
130
|
|
|
90
131
|
## v1.3.3 - 2020-01-14
|
|
132
|
+
|
|
91
133
|
### Added
|
|
134
|
+
|
|
92
135
|
- [Luca Guidi] Official support for Ruby: MRI 2.7
|
|
93
136
|
- [Luca Guidi] Support `rack` 2.1
|
|
94
137
|
- [Luca Guidi] Support for both `hanami-validations` 1 and 2
|
|
95
138
|
|
|
96
139
|
## v1.3.2 - 2019-06-28
|
|
140
|
+
|
|
97
141
|
### Fixed
|
|
142
|
+
|
|
98
143
|
- [Ian Ker-Seymer] Ensure `Etag` to work when `If-Modified-Since` is sent from browser and upstream proxy sets `Last-Modified` automatically.
|
|
99
144
|
|
|
100
145
|
## v1.3.1 - 2019-01-18
|
|
146
|
+
|
|
101
147
|
### Added
|
|
148
|
+
|
|
102
149
|
- [Luca Guidi] Official support for Ruby: MRI 2.6
|
|
103
150
|
- [Luca Guidi] Support `bundler` 2.0+
|
|
104
151
|
|
|
105
152
|
## v1.3.0 - 2018-10-24
|
|
153
|
+
|
|
106
154
|
### Added
|
|
155
|
+
|
|
107
156
|
- [Gustavo Caso] Swappable JSON backed for `Hanami::Action::Flash` based on `Hanami::Utils::Json`
|
|
108
157
|
|
|
109
158
|
## v1.3.0.beta1 - 2018-08-08
|
|
159
|
+
|
|
110
160
|
### Added
|
|
161
|
+
|
|
111
162
|
- [Luca Guidi] Official support for JRuby 9.2.0.0
|
|
112
163
|
|
|
113
164
|
### Fixed
|
|
165
|
+
|
|
114
166
|
- [Yuji Ueki] Ensure that if `If-None-Match` or `If-Modified-Since` response HTTP headers are missing, `Etag` or `Last-Modified` headers will be in response HTTP headers.
|
|
115
167
|
- [Gustavo Caso] Don't show flash message for the request after a HTTP redirect.
|
|
116
168
|
- [Gustavo Caso] Ensure `Hanami::Action::Flash#each`, `#map`, and `#empty?` to not reference stale flash data.
|
|
117
169
|
|
|
118
170
|
### Deprecated
|
|
171
|
+
|
|
119
172
|
- [Gustavo Caso] Deprecate `Hanami::Action#parsed_request_body`
|
|
120
173
|
|
|
121
174
|
## v1.2.0 - 2018-04-11
|
|
122
175
|
|
|
123
176
|
## v1.2.0.rc2 - 2018-04-06
|
|
177
|
+
|
|
124
178
|
### Added
|
|
179
|
+
|
|
125
180
|
- [Gustavo Caso] Introduce `Hanami::Action::Flash#each` and `#map`
|
|
126
181
|
|
|
127
182
|
## v1.2.0.rc1 - 2018-03-30
|
|
@@ -129,20 +184,27 @@ Complete, fast and testable actions for Rack
|
|
|
129
184
|
## v1.2.0.beta2 - 2018-03-23
|
|
130
185
|
|
|
131
186
|
## v1.2.0.beta1 - 2018-02-28
|
|
187
|
+
|
|
132
188
|
### Added
|
|
189
|
+
|
|
133
190
|
- [Luca Guidi] Official support for Ruby: MRI 2.5
|
|
134
191
|
- [Sergey Fedorov] Introduce `Hanami::Action.content_type` to accept/reject requests according to their `Content-Type` header.
|
|
135
192
|
|
|
136
193
|
### Fixed
|
|
194
|
+
|
|
137
195
|
- [wheresmyjetpack] Raise meaningful exception when trying to access `session` or `flash` and `Hanami::Action::Session` wasn't included.
|
|
138
196
|
|
|
139
197
|
## v1.1.1 - 2017-11-22
|
|
198
|
+
|
|
140
199
|
### Fixed
|
|
200
|
+
|
|
141
201
|
- [Luca Guidi] Ensure `Hanami::Action#send_file` and `#unsafe_send_file` to run `after` action callbacks
|
|
142
202
|
- [Luca Guidi] Ensure Rack env to have the `REQUEST_METHOD` key set to `GET` during actions unit tests
|
|
143
203
|
|
|
144
204
|
## v1.1.0 - 2017-10-25
|
|
205
|
+
|
|
145
206
|
### Added
|
|
207
|
+
|
|
146
208
|
- [Luca Guidi] Introduce `Hanami::Action::CookieJar#each` to iterate through action's `cookies`
|
|
147
209
|
|
|
148
210
|
## v1.1.0.rc1 - 2017-10-16
|
|
@@ -150,13 +212,17 @@ Complete, fast and testable actions for Rack
|
|
|
150
212
|
## v1.1.0.beta3 - 2017-10-04
|
|
151
213
|
|
|
152
214
|
## v1.1.0.beta2 - 2017-10-03
|
|
215
|
+
|
|
153
216
|
### Added
|
|
217
|
+
|
|
154
218
|
- [Luca Guidi] Introduce `Hanami::Action::Params::Errors#add` to add errors not generated by params validations
|
|
155
219
|
|
|
156
220
|
## v1.1.0.beta1 - 2017-08-11
|
|
157
221
|
|
|
158
222
|
## v1.0.1 - 2017-07-10
|
|
223
|
+
|
|
159
224
|
### Fixed
|
|
225
|
+
|
|
160
226
|
- [Marcello Rocha] Ensure validation params to be symbolized in all the environments
|
|
161
227
|
- [Marcello Rocha] Fix regression (`1.0.0`) about MIME type priority, during the evaluation of a weighted `Accept` HTTP header
|
|
162
228
|
|
|
@@ -165,69 +231,92 @@ Complete, fast and testable actions for Rack
|
|
|
165
231
|
## v1.0.0.rc1 - 2017-03-31
|
|
166
232
|
|
|
167
233
|
## v1.0.0.beta3 - 2017-03-17
|
|
234
|
+
|
|
168
235
|
### Changed
|
|
236
|
+
|
|
169
237
|
- [Luca Guidi] `Action#flash` is now public API
|
|
170
238
|
|
|
171
239
|
## v1.0.0.beta2 - 2017-03-02
|
|
240
|
+
|
|
172
241
|
### Added
|
|
242
|
+
|
|
173
243
|
- [Marcello Rocha] Add `Action#unsafe_send_file` to send files outside of the public directory of a project
|
|
174
244
|
|
|
175
245
|
### Fixed
|
|
246
|
+
|
|
176
247
|
- [Anton Davydov] Ensure HTTP Cache to not crash when `HTTP_IF_MODIFIED_SINCE` and `HTTP_IF_NONE_MATCH` have blank values
|
|
177
248
|
- [Luca Guidi] Keep flash values after a redirect
|
|
178
249
|
- [Craig M. Wellington & Luca Guidi] Ensure to return 404 when `Action#send_file` cannot find a file with a globbed route
|
|
179
250
|
- [Luca Guidi] Don't mutate Rack env when sending files
|
|
180
251
|
|
|
181
252
|
## v1.0.0.beta1 - 2017-02-14
|
|
253
|
+
|
|
182
254
|
### Added
|
|
255
|
+
|
|
183
256
|
- [Luca Guidi] Official support for Ruby: MRI 2.4
|
|
184
257
|
|
|
185
258
|
### Fixed
|
|
259
|
+
|
|
186
260
|
- [Marcello Rocha & Luca Guidi] Avoid MIME type conflicts for `Action#format` detection
|
|
187
261
|
- [Matias H. Leidemer & Luca Guidi] Ensure `Flash` to return only fresh data
|
|
188
262
|
- [Luca Guidi] Ensure `session` keys to be accessed as symbols in action unit tests
|
|
189
263
|
|
|
190
264
|
### Changed
|
|
265
|
+
|
|
191
266
|
- [Anton Davydov & Luca Guidi] Make it work only with Rack 2.0
|
|
192
267
|
|
|
193
268
|
## v0.8.1 - 2016-12-19
|
|
269
|
+
|
|
194
270
|
### Fixed
|
|
271
|
+
|
|
195
272
|
- [Thorbjørn Hermansen] Don't pollute Rack env's `rack.exception` key if an exception is handled
|
|
196
273
|
- [Luca Guidi] Add `flash` to the default exposures
|
|
197
274
|
|
|
198
275
|
## v0.8.0 - 2016-11-15
|
|
276
|
+
|
|
199
277
|
### Added
|
|
278
|
+
|
|
200
279
|
- [Marion Duprey] Allow `BaseParams#get` to read (nested) arrays
|
|
201
280
|
|
|
202
281
|
### Fixed
|
|
282
|
+
|
|
203
283
|
- [Russell Cloak] Respect custom formats when referenced by HTTP `Accept`
|
|
204
284
|
- [Kyle Chong] Don't symbolize raw params
|
|
205
285
|
|
|
206
286
|
### Changed
|
|
287
|
+
|
|
207
288
|
- [Luca Guidi] Let `BaseParams#get` to accept a list of keys (symbols) instead of string with dot notation (`params.get(:customer, :address, :city)` instead of `params.get('customer.address.city')`)
|
|
208
289
|
|
|
209
290
|
## v0.7.1 - 2016-10-06
|
|
291
|
+
|
|
210
292
|
### Added
|
|
293
|
+
|
|
211
294
|
- [Kyle Chong] Introduced `parsed_request_body` for action
|
|
212
295
|
- [Luca Guidi] Introduced `Hanami::Action::BaseParams#each`
|
|
213
296
|
|
|
214
297
|
### Fixed
|
|
298
|
+
|
|
215
299
|
- [Ayleen McCann] Use default content type when `HTTP_ACCEPT` is `*/*`
|
|
216
300
|
- [Kyle Chong] Don't stringify uploaded files
|
|
217
301
|
- [Kyle Chong] Don't stringify params values when not necessary
|
|
218
302
|
|
|
219
303
|
### Changed
|
|
304
|
+
|
|
220
305
|
- [akhramov & Luca Guidi] Raise `Hanami::Controller::IllegalExposureError` when try to expose reserved words: `params`, and `flash`.
|
|
221
306
|
|
|
222
307
|
## v0.7.0 - 2016-07-22
|
|
308
|
+
|
|
223
309
|
### Added
|
|
310
|
+
|
|
224
311
|
- [Luca Guidi] Introduced `Hanami::Action::Params#error_messages` which returns a flat collection of full error messages
|
|
225
312
|
|
|
226
313
|
### Fixed
|
|
314
|
+
|
|
227
315
|
- [Luca Guidi] Params are deeply symbolized
|
|
228
316
|
- [Artem Nistratov] Send only changed cookies in HTTP response
|
|
229
317
|
|
|
230
318
|
### Changed
|
|
319
|
+
|
|
231
320
|
- [Luca Guidi] Drop support for Ruby 2.0 and 2.1. Official support for JRuby 9.0.5.0+.
|
|
232
321
|
- [Luca Guidi] Param validations now require you to add `hanami-validations` in `Gemfile`.
|
|
233
322
|
- [Luca Guidi] Removed "_indifferent access_" for params. Since now on, only symbols are allowed.
|
|
@@ -237,80 +326,110 @@ Complete, fast and testable actions for Rack
|
|
|
237
326
|
- [Vasilis Spilka] Made `Hanami::Action::Session#errors` public
|
|
238
327
|
|
|
239
328
|
## v0.6.1 - 2016-02-05
|
|
329
|
+
|
|
240
330
|
### Changed
|
|
331
|
+
|
|
241
332
|
- [Anatolii Didukh] Optimise memory usage by freezing MIME types constant
|
|
242
333
|
|
|
243
334
|
## v0.6.0 - 2016-01-22
|
|
335
|
+
|
|
244
336
|
### Changed
|
|
337
|
+
|
|
245
338
|
- [Luca Guidi] Renamed the project
|
|
246
339
|
|
|
247
340
|
## v0.5.1 - 2016-01-19
|
|
341
|
+
|
|
248
342
|
### Fixed
|
|
343
|
+
|
|
249
344
|
- [Alfonso Uceda] Ensure `rack.session` cookie to not be sent twice when both `Lotus::Action::Cookies` and `Rack::Session::Cookie` are used together
|
|
250
345
|
|
|
251
346
|
## v0.5.0 - 2016-01-12
|
|
347
|
+
|
|
252
348
|
### Added
|
|
349
|
+
|
|
253
350
|
- [Luca Guidi] Reference a raised exception in Rack env's `rack.exception`. Compatibility with exception reporting SaaS.
|
|
254
351
|
|
|
255
352
|
### Fixed
|
|
353
|
+
|
|
256
354
|
- [Cainã Costa] Ensure Rack environment to be always available for sessions unit tests
|
|
257
355
|
- [Luca Guidi] Ensure superclass exceptions to not shadow subclasses during exception handling (eg. `CustomError` handler will take precedence over `StandardError`)
|
|
258
356
|
|
|
259
357
|
### Changed
|
|
358
|
+
|
|
260
359
|
- [Luca Guidi] Removed `Lotus::Controller::Configuration#default_format`
|
|
261
360
|
- [Cainã Costa] Made `Lotus::Action#session` a public method for improved unit testing
|
|
262
361
|
- [Karim Tarek] Introduced `Lotus::Controller::Error` and let all the framework exceptions to inherit from it.
|
|
263
362
|
|
|
264
363
|
## v0.4.6 - 2015-12-04
|
|
364
|
+
|
|
265
365
|
### Added
|
|
366
|
+
|
|
266
367
|
- [Luca Guidi] Allow to force custom headers for responses that according to RFC shouldn't include them (eg 204). Override `#keep_response_header?(header)` in action
|
|
267
368
|
|
|
268
369
|
## v0.4.5 - 2015-09-30
|
|
370
|
+
|
|
269
371
|
### Added
|
|
372
|
+
|
|
270
373
|
- [Theo Felippe] Added configuration entries: `#default_request_format` and `default_response_format`.
|
|
271
374
|
- [Wellington Santos] Error handling to take account of inherited exceptions.
|
|
272
375
|
|
|
273
376
|
### Changed
|
|
377
|
+
|
|
274
378
|
- [Theo Felippe] Deprecated `#default_format` in favor of: `#default_request_format`.
|
|
275
379
|
|
|
276
380
|
## v0.4.4 - 2015-06-23
|
|
381
|
+
|
|
277
382
|
### Added
|
|
383
|
+
|
|
278
384
|
- [Luca Guidi] Security protection against Cross Site Request Forgery (CSRF).
|
|
279
385
|
|
|
280
386
|
### Fixed
|
|
387
|
+
|
|
281
388
|
- [Matthew Bellantoni] Ensure nested params to be correctly coerced to Hash.
|
|
282
389
|
|
|
283
390
|
## v0.4.3 - 2015-05-22
|
|
391
|
+
|
|
284
392
|
### Added
|
|
393
|
+
|
|
285
394
|
- [Alfonso Uceda Pompa & Luca Guidi] Introduced `Lotus::Action#send_file`
|
|
286
395
|
- [Alfonso Uceda Pompa] Set automatically `Expires` option for cookies when it's missing but `Max-Age` is present. Compatibility with old browsers.
|
|
287
396
|
|
|
288
397
|
## v0.4.2 - 2015-05-15
|
|
398
|
+
|
|
289
399
|
### Fixed
|
|
400
|
+
|
|
290
401
|
- [Luca Guidi] Ensure `Lotus::Action::Params#to_h` to return `::Hash` at the top level
|
|
291
402
|
|
|
292
403
|
## v0.4.1 - 2015-05-15
|
|
404
|
+
|
|
293
405
|
### Fixed
|
|
406
|
+
|
|
294
407
|
- [Luca Guidi] Ensure proper automatic `Content-Type` working well with Internet Explorer.
|
|
295
408
|
- [Luca Guidi] Ensure `Lotus::Action#redirect_to` to return `::String` for Rack servers compatibility.
|
|
296
409
|
|
|
297
410
|
### Changed
|
|
411
|
+
|
|
298
412
|
- [Alfonso Uceda Pompa] Prevent `Content-Type` and `Content-Lenght` to be sent when status code requires no body (eg. `204`).
|
|
299
|
-
|
|
413
|
+
This is for compatibility with `Rack::Lint`, not with RFC 2016.
|
|
300
414
|
- [Luca Guidi] Ensure `Lotus::Action::Params#to_h` to return `::Hash`
|
|
301
415
|
|
|
302
416
|
## v0.4.0 - 2015-03-23
|
|
417
|
+
|
|
303
418
|
### Added
|
|
419
|
+
|
|
304
420
|
- [Erol Fornoles] `Action.use` now accepts a block
|
|
305
421
|
- [Alfonso Uceda Pompa] Introduced `Lotus::Controller::Configuration#cookies` as default cookie options.
|
|
306
422
|
- [Alfonso Uceda Pompa] Introduced `Lotus::Controller::Configuration#default_headers` as default HTTP headers to return in all the responses.
|
|
307
423
|
- [Luca Guidi] Introduced `Lotus::Action::Params#get` as a safe API to access nested params.
|
|
308
424
|
|
|
309
425
|
### Changed
|
|
426
|
+
|
|
310
427
|
- [Alfonso Uceda Pompa] `redirect_to` now is a flow control method: it terminates the execution of an action, including the callbacks.
|
|
311
428
|
|
|
312
429
|
## v0.3.2 - 2015-01-30
|
|
430
|
+
|
|
313
431
|
### Added
|
|
432
|
+
|
|
314
433
|
- [Alfonso Uceda Pompa] Callbacks: introduced `append_before` (alias of `before`), `append_after` (alias of `after`), `prepend_before` and `prepend_after`.
|
|
315
434
|
- [Alfonso Uceda Pompa] Introduced `Lotus::Action::Params#raw` which returns unfiltered data as it comes from an HTTP request.
|
|
316
435
|
- [Alfonso Uceda Pompa] `Lotus::Action::Rack.use` now fully supports Rack middleware, by mounting an internal `Rack::Builder` instance.
|
|
@@ -318,20 +437,26 @@ Complete, fast and testable actions for Rack
|
|
|
318
437
|
- [Steve Hodgkiss] Nested params validation
|
|
319
438
|
|
|
320
439
|
### Fixed
|
|
440
|
+
|
|
321
441
|
- [Luca Guidi] Ensure HEAD requests will return empty body
|
|
322
442
|
- [Stefano Verna] Ensure HTTP status codes with empty body won't send body and non-entity headers.
|
|
323
443
|
- [Luca Guidi] Only dump exceptions in `rack.errors` if handling is turned off, or the raised exception is not managed.
|
|
324
444
|
- [Luca Guidi] Ensure params will return coerced values
|
|
325
445
|
|
|
326
446
|
## v0.3.1 - 2015-01-08
|
|
447
|
+
|
|
327
448
|
### Added
|
|
449
|
+
|
|
328
450
|
- [Lasse Skindstad Ebert] Introduced `Action#request` which returns an instance a `Rack::Request` compliant object: `Lotus::Action::Request`.
|
|
329
451
|
|
|
330
452
|
### Fixed
|
|
453
|
+
|
|
331
454
|
- [Steve Hodgkiss] Ensure params to return coerced values
|
|
332
455
|
|
|
333
456
|
## v0.3.0 - 2014-12-23
|
|
457
|
+
|
|
334
458
|
### Added
|
|
459
|
+
|
|
335
460
|
- [Luca Guidi] Introduced `Action#request_id` as unique identifier for an incoming HTTP request
|
|
336
461
|
- [Luca Guidi] Introduced `Lotus::Controller.load!` as loading framework entry point
|
|
337
462
|
- [Kir Shatrov] Allow to define a default charset (`default_charset` configuration)
|
|
@@ -347,6 +472,7 @@ Complete, fast and testable actions for Rack
|
|
|
347
472
|
- [Luca Guidi] Official support for Ruby 2.2
|
|
348
473
|
|
|
349
474
|
### Changed
|
|
475
|
+
|
|
350
476
|
- [Trung Lê] Renamed `Configuration#modules` to `#prepare`
|
|
351
477
|
- [Luca Guidi] Update HTTP status codes to IETF RFC 7231
|
|
352
478
|
- [Luca Guidi] When `Lotus::Controller` is included, don't inject code
|
|
@@ -355,30 +481,37 @@ Complete, fast and testable actions for Rack
|
|
|
355
481
|
- [Fuad Saud] Reduce method visibility where possible (Ruby `private` and `protected`)
|
|
356
482
|
|
|
357
483
|
### Fixed
|
|
484
|
+
|
|
358
485
|
- [Luca Guidi] Don't let exposures definition to override existing methods
|
|
359
486
|
|
|
360
487
|
## v0.2.0 - 2014-06-23
|
|
488
|
+
|
|
361
489
|
### Added
|
|
490
|
+
|
|
362
491
|
- [Luca Guidi] Introduced `Controller.configure` and `Controller.duplicate`
|
|
363
492
|
- [Luca Guidi] Introduced `Action.use`, that let to use a Rack middleware as a before callback
|
|
364
|
-
– [Luca Guidi] Allow to define a default mime type when the request is `Accept: */*` (`default_format` configuration)
|
|
365
|
-
– [Luca Guidi] Allow to register custom mime types and associate them to a symbol (`format` configuration)
|
|
493
|
+
– [Luca Guidi] Allow to define a default mime type when the request is `Accept: */*` (`default_format` configuration)
|
|
494
|
+
– [Luca Guidi] Allow to register custom mime types and associate them to a symbol (`format` configuration)
|
|
366
495
|
- [Luca Guidi] Introduced `Configuration#handle_exceptions` to associate exceptions to HTTP statuses
|
|
367
496
|
- [Damir Zekic] Allow developers to toggle exception handling (`handle_exceptions` configuration)
|
|
368
497
|
- [Luca Guidi] Introduced `Controller::Configuration`
|
|
369
498
|
- [Luca Guidi] Official support for Ruby 2.1
|
|
370
499
|
|
|
371
500
|
### Changed
|
|
501
|
+
|
|
372
502
|
- [Luca Guidi] `Lotus::Action::Params` doesn't inherit from `Lotus::Utils::Hash` anymore
|
|
373
503
|
- [Luca Guidi] `Lotus::Action::CookieJar` doesn't inherit from `Lotus::Utils::Hash` anymore
|
|
374
504
|
- [Luca Guidi] Make HTTP status messages compliant with IANA and Rack
|
|
375
505
|
- [Damir Zekic] Moved `#throw` override logic into `#halt`, which keeps the same semantic
|
|
376
506
|
|
|
377
507
|
### Fixed
|
|
508
|
+
|
|
378
509
|
- [Krzysztof Zalewski] Reference exception in `rack.errors`
|
|
379
510
|
|
|
380
511
|
## v0.1.0 - 2014-02-23
|
|
512
|
+
|
|
381
513
|
### Added
|
|
514
|
+
|
|
382
515
|
- [Luca Guidi] Introduced `Action.accept` to whitelist accepted mime types
|
|
383
516
|
- [Luca Guidi] Introduced `Action#accept?` as a query method for the current request
|
|
384
517
|
- [Luca Guidi] Allow to whitelist handled exceptions and associate them to an HTTP status
|
data/README.md
CHANGED
|
@@ -26,14 +26,14 @@ Complete, fast and testable actions for Rack and [Hanami](http://hanamirb.org)
|
|
|
26
26
|
|
|
27
27
|
## Rubies
|
|
28
28
|
|
|
29
|
-
__Hanami::Controller__ supports Ruby (MRI)
|
|
29
|
+
__Hanami::Controller__ supports Ruby (MRI) 3.0+
|
|
30
30
|
|
|
31
31
|
## Installation
|
|
32
32
|
|
|
33
33
|
Add this line to your application's Gemfile:
|
|
34
34
|
|
|
35
35
|
```ruby
|
|
36
|
-
gem "hanami
|
|
36
|
+
gem "hanami-controller"
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
And then execute:
|
|
@@ -967,6 +967,4 @@ __Hanami::Controller__ uses [Semantic Versioning 2.0.0](http://semver.org)
|
|
|
967
967
|
|
|
968
968
|
## Copyright
|
|
969
969
|
|
|
970
|
-
Copyright © 2014-
|
|
971
|
-
|
|
972
|
-
This project was formerly known as Lotus (`lotus-controller`).
|
|
970
|
+
Copyright © 2014-2022 Hanami Team – Released under MIT License
|
data/hanami-controller.gemspec
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require
|
|
5
|
+
require "hanami/controller/version"
|
|
5
6
|
|
|
6
7
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name =
|
|
8
|
+
spec.name = "hanami-controller"
|
|
8
9
|
spec.version = Hanami::Controller::VERSION
|
|
9
|
-
spec.authors = [
|
|
10
|
-
spec.email = [
|
|
11
|
-
spec.description =
|
|
12
|
-
spec.summary =
|
|
13
|
-
spec.homepage =
|
|
14
|
-
spec.license =
|
|
10
|
+
spec.authors = ["Luca Guidi"]
|
|
11
|
+
spec.email = ["me@lucaguidi.com"]
|
|
12
|
+
spec.description = "Complete, fast and testable actions for Rack"
|
|
13
|
+
spec.summary = "Complete, fast and testable actions for Rack and Hanami"
|
|
14
|
+
spec.homepage = "http://hanamirb.org"
|
|
15
|
+
spec.license = "MIT"
|
|
15
16
|
|
|
16
17
|
spec.files = `git ls-files -- lib/* CHANGELOG.md LICENSE.md README.md hanami-controller.gemspec`.split($/)
|
|
17
18
|
spec.executables = []
|
|
18
|
-
spec.
|
|
19
|
-
spec.
|
|
20
|
-
spec.required_ruby_version =
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
21
|
+
spec.required_ruby_version = ">= 3.0"
|
|
21
22
|
|
|
22
|
-
spec.add_dependency
|
|
23
|
-
spec.add_dependency
|
|
24
|
-
spec.add_dependency
|
|
23
|
+
spec.add_dependency "rack", "~> 2.0"
|
|
24
|
+
spec.add_dependency "hanami-utils", "~> 2.0.beta"
|
|
25
|
+
spec.add_dependency "dry-configurable", "~> 0.13", ">= 0.13.0"
|
|
25
26
|
|
|
26
|
-
spec.add_development_dependency
|
|
27
|
-
spec.add_development_dependency
|
|
28
|
-
spec.add_development_dependency
|
|
29
|
-
spec.add_development_dependency
|
|
27
|
+
spec.add_development_dependency "bundler", ">= 1.6", "< 3"
|
|
28
|
+
spec.add_development_dependency "rack-test", "~> 2.0"
|
|
29
|
+
spec.add_development_dependency "rake", "~> 13"
|
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
|
31
|
+
spec.add_development_dependency "rubocop", "~> 1.0"
|
|
30
32
|
end
|
|
@@ -1,46 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rack/request"
|
|
4
|
+
require "hanami/utils/hash"
|
|
3
5
|
|
|
4
6
|
module Hanami
|
|
5
7
|
class Action
|
|
6
8
|
class BaseParams
|
|
7
|
-
# The key that returns raw input from the Rack env
|
|
8
|
-
#
|
|
9
|
-
# @since 0.7.0
|
|
10
|
-
# @api private
|
|
11
|
-
RACK_INPUT = 'rack.input'.freeze
|
|
12
|
-
|
|
13
|
-
# The key that returns router params from the Rack env
|
|
14
|
-
# This is a builtin integration for Hanami::Router
|
|
15
|
-
#
|
|
16
|
-
# @since 0.7.0
|
|
17
|
-
# @api private
|
|
18
|
-
ROUTER_PARAMS = 'router.params'.freeze
|
|
19
|
-
|
|
20
|
-
# The key that returns Rack session params from the Rack env
|
|
21
|
-
# Please note that this is used only when an action is unit tested.
|
|
22
|
-
#
|
|
23
|
-
# @since 1.0.0
|
|
24
|
-
# @api private
|
|
25
|
-
#
|
|
26
|
-
# @example
|
|
27
|
-
# # action unit test
|
|
28
|
-
# action.call('rack.session' => { 'foo' => 'bar' })
|
|
29
|
-
# action.session[:foo] # => "bar"
|
|
30
|
-
RACK_SESSION = 'rack.session'.freeze
|
|
31
|
-
|
|
32
|
-
# HTTP request method for Rack env
|
|
33
|
-
#
|
|
34
|
-
# @since 1.1.1
|
|
35
|
-
# @api private
|
|
36
|
-
REQUEST_METHOD = 'REQUEST_METHOD'.freeze
|
|
37
|
-
|
|
38
|
-
# Default HTTP request method for Rack env
|
|
39
|
-
#
|
|
40
|
-
# @since 1.1.1
|
|
41
|
-
# @api private
|
|
42
|
-
DEFAULT_REQUEST_METHOD = 'GET'.freeze
|
|
43
|
-
|
|
44
9
|
# @attr_reader env [Hash] the Rack env
|
|
45
10
|
#
|
|
46
11
|
# @since 0.7.0
|
|
@@ -89,24 +54,22 @@ module Hanami
|
|
|
89
54
|
# @since 0.7.0
|
|
90
55
|
#
|
|
91
56
|
# @example
|
|
92
|
-
# require
|
|
57
|
+
# require "hanami/controller"
|
|
93
58
|
#
|
|
94
59
|
# module Deliveries
|
|
95
|
-
# class Create
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
-
# params.get(:customer_name) # => "Luca"
|
|
100
|
-
# params.get(:uknown) # => nil
|
|
60
|
+
# class Create < Hanami::Action
|
|
61
|
+
# def handle(req, *)
|
|
62
|
+
# req.params.get(:customer_name) # => "Luca"
|
|
63
|
+
# req.params.get(:uknown) # => nil
|
|
101
64
|
#
|
|
102
|
-
# params.get(:address, :city) # => "Rome"
|
|
103
|
-
# params.get(:address, :unknown) # => nil
|
|
65
|
+
# req.params.get(:address, :city) # => "Rome"
|
|
66
|
+
# req.params.get(:address, :unknown) # => nil
|
|
104
67
|
#
|
|
105
|
-
# params.get(:tags, 0) # => "foo"
|
|
106
|
-
# params.get(:tags, 1) # => "bar"
|
|
107
|
-
# params.get(:tags, 999) # => nil
|
|
68
|
+
# req.params.get(:tags, 0) # => "foo"
|
|
69
|
+
# req.params.get(:tags, 1) # => "bar"
|
|
70
|
+
# req.params.get(:tags, 999) # => nil
|
|
108
71
|
#
|
|
109
|
-
# params.get(nil) # => nil
|
|
72
|
+
# req.params.get(nil) # => nil
|
|
110
73
|
# end
|
|
111
74
|
# end
|
|
112
75
|
# end
|
|
@@ -118,7 +81,7 @@ module Hanami
|
|
|
118
81
|
#
|
|
119
82
|
# @api private
|
|
120
83
|
# @since 0.8.0
|
|
121
|
-
|
|
84
|
+
alias_method :dig, :get
|
|
122
85
|
|
|
123
86
|
# Provide a common interface with Params
|
|
124
87
|
#
|
|
@@ -157,12 +120,12 @@ module Hanami
|
|
|
157
120
|
def _extract_params
|
|
158
121
|
result = {}
|
|
159
122
|
|
|
160
|
-
if env.key?(RACK_INPUT)
|
|
123
|
+
if env.key?(Action::RACK_INPUT)
|
|
161
124
|
result.merge! ::Rack::Request.new(env).params
|
|
162
125
|
result.merge! _router_params
|
|
163
126
|
else
|
|
164
127
|
result.merge! _router_params(env)
|
|
165
|
-
env[REQUEST_METHOD] ||= DEFAULT_REQUEST_METHOD
|
|
128
|
+
env[Action::REQUEST_METHOD] ||= Action::DEFAULT_REQUEST_METHOD
|
|
166
129
|
end
|
|
167
130
|
|
|
168
131
|
result
|
|
@@ -172,8 +135,8 @@ module Hanami
|
|
|
172
135
|
# @api private
|
|
173
136
|
def _router_params(fallback = {})
|
|
174
137
|
env.fetch(ROUTER_PARAMS) do
|
|
175
|
-
if session = fallback.delete(RACK_SESSION)
|
|
176
|
-
fallback[RACK_SESSION] = Utils::Hash.deep_symbolize(session)
|
|
138
|
+
if session = fallback.delete(Action::RACK_SESSION)
|
|
139
|
+
fallback[Action::RACK_SESSION] = Utils::Hash.deep_symbolize(session)
|
|
177
140
|
end
|
|
178
141
|
|
|
179
142
|
fallback
|