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