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