hanami-controller 2.0.2 → 2.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/LICENSE.md +1 -1
- data/README.md +1 -1
- data/lib/hanami/action/request.rb +16 -5
- data/lib/hanami/action/response.rb +14 -4
- data/lib/hanami/action/session.rb +1 -1
- data/lib/hanami/action.rb +4 -4
- data/lib/hanami/controller/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58299df4276e04c035c82a7afcf6c012bd5059213d5fcc375ecc2e001900aa9b
|
4
|
+
data.tar.gz: 9c7d4d3a80766da72364f2eee2d6909785a70ef9c63f6e1739d46af11bd9e49b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63d21bbd06003cac35e8b12d94fb829bdaf9a95164b948a7059aab745cb49ca8b9f100b7ac27a244a9cd9c4e9c1db6a1c7cb0c279859e6bf56eb75aa846bfd1c
|
7
|
+
data.tar.gz: a04360570cf34f82caff342a04a2d46ca55c951c3aa718c1c15d0ff723f79b9b87b56e8e8ec57489a9f4d06a10ec35ad7f1681b9e6695aa393943a97c191fc99
|
data/CHANGELOG.md
CHANGED
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -29,11 +29,11 @@ module Hanami
|
|
29
29
|
|
30
30
|
# @since 2.0.0
|
31
31
|
# @api private
|
32
|
-
def initialize(env:, params:,
|
32
|
+
def initialize(env:, params:, session_enabled: false)
|
33
33
|
super(env)
|
34
34
|
|
35
35
|
@params = params
|
36
|
-
@
|
36
|
+
@session_enabled = session_enabled
|
37
37
|
end
|
38
38
|
|
39
39
|
# Returns the request's ID
|
@@ -47,18 +47,29 @@ module Hanami
|
|
47
47
|
@id ||= @env[Action::REQUEST_ID] = SecureRandom.hex(Action::DEFAULT_ID_LENGTH)
|
48
48
|
end
|
49
49
|
|
50
|
+
# Returns true if the session is enabled for the request.
|
51
|
+
#
|
52
|
+
# @return [Boolean]
|
53
|
+
#
|
54
|
+
# @api public
|
55
|
+
# @since 2.1.0
|
56
|
+
def session_enabled?
|
57
|
+
@session_enabled
|
58
|
+
end
|
59
|
+
|
50
60
|
# Returns the session for the request.
|
51
61
|
#
|
52
62
|
# @return [Hash] the session object
|
53
63
|
#
|
54
|
-
# @raise [MissingSessionError] if
|
64
|
+
# @raise [MissingSessionError] if the session is not enabled
|
55
65
|
#
|
66
|
+
# @see #session_enabled?
|
56
67
|
# @see Response#session
|
57
68
|
#
|
58
69
|
# @since 2.0.0
|
59
70
|
# @api public
|
60
71
|
def session
|
61
|
-
unless
|
72
|
+
unless session_enabled?
|
62
73
|
raise Hanami::Action::MissingSessionError.new("Hanami::Action::Request#session")
|
63
74
|
end
|
64
75
|
|
@@ -76,7 +87,7 @@ module Hanami
|
|
76
87
|
# @since 2.0.0
|
77
88
|
# @api public
|
78
89
|
def flash
|
79
|
-
unless
|
90
|
+
unless session_enabled?
|
80
91
|
raise Hanami::Action::MissingSessionError.new("Hanami::Action::Request#flash")
|
81
92
|
end
|
82
93
|
|
@@ -48,7 +48,7 @@ module Hanami
|
|
48
48
|
|
49
49
|
# @since 2.0.0
|
50
50
|
# @api private
|
51
|
-
def initialize(request:, config:, content_type: nil, env: {}, headers: {}, view_options: nil,
|
51
|
+
def initialize(request:, config:, content_type: nil, env: {}, headers: {}, view_options: nil, session_enabled: false) # rubocop:disable Layout/LineLength, Metrics/ParameterLists
|
52
52
|
super([], 200, headers.dup)
|
53
53
|
self.content_type = content_type if content_type
|
54
54
|
|
@@ -59,7 +59,7 @@ module Hanami
|
|
59
59
|
@env = env
|
60
60
|
@view_options = view_options || DEFAULT_VIEW_OPTIONS
|
61
61
|
|
62
|
-
@
|
62
|
+
@session_enabled = session_enabled
|
63
63
|
@sending_file = false
|
64
64
|
end
|
65
65
|
|
@@ -187,6 +187,16 @@ module Hanami
|
|
187
187
|
@exposures[key] = value
|
188
188
|
end
|
189
189
|
|
190
|
+
# Returns true if the session is enabled for the request.
|
191
|
+
#
|
192
|
+
# @return [Boolean]
|
193
|
+
#
|
194
|
+
# @api public
|
195
|
+
# @since 2.1.0
|
196
|
+
def session_enabled?
|
197
|
+
@session_enabled
|
198
|
+
end
|
199
|
+
|
190
200
|
# Returns the session for the response.
|
191
201
|
#
|
192
202
|
# This is the same session object as the {Request}.
|
@@ -200,7 +210,7 @@ module Hanami
|
|
200
210
|
# @since 2.0.0
|
201
211
|
# @api public
|
202
212
|
def session
|
203
|
-
unless
|
213
|
+
unless session_enabled?
|
204
214
|
raise Hanami::Action::MissingSessionError.new("Hanami::Action::Response#session")
|
205
215
|
end
|
206
216
|
|
@@ -220,7 +230,7 @@ module Hanami
|
|
220
230
|
# @since 2.0.0
|
221
231
|
# @api public
|
222
232
|
def flash
|
223
|
-
unless
|
233
|
+
unless session_enabled?
|
224
234
|
raise Hanami::Action::MissingSessionError.new("Hanami::Action::Response#flash")
|
225
235
|
end
|
226
236
|
|
data/lib/hanami/action.rb
CHANGED
@@ -309,7 +309,7 @@ module Hanami
|
|
309
309
|
request = build_request(
|
310
310
|
env: env,
|
311
311
|
params: params,
|
312
|
-
|
312
|
+
session_enabled: session_enabled?
|
313
313
|
)
|
314
314
|
response = build_response(
|
315
315
|
request: request,
|
@@ -317,7 +317,7 @@ module Hanami
|
|
317
317
|
content_type: Mime.response_content_type_with_charset(request, config),
|
318
318
|
env: env,
|
319
319
|
headers: config.default_headers,
|
320
|
-
|
320
|
+
session_enabled: session_enabled?
|
321
321
|
)
|
322
322
|
|
323
323
|
enforce_accepted_mime_types(request)
|
@@ -424,10 +424,10 @@ module Hanami
|
|
424
424
|
nil
|
425
425
|
end
|
426
426
|
|
427
|
-
# @see Session#
|
427
|
+
# @see Session#session_enabled?
|
428
428
|
# @since 2.0.0
|
429
429
|
# @api private
|
430
|
-
def
|
430
|
+
def session_enabled?
|
431
431
|
false
|
432
432
|
end
|
433
433
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -218,11 +218,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '3.0'
|
219
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
220
|
requirements:
|
221
|
-
- - "
|
221
|
+
- - ">"
|
222
222
|
- !ruby/object:Gem::Version
|
223
|
-
version:
|
223
|
+
version: 1.3.1
|
224
224
|
requirements: []
|
225
|
-
rubygems_version: 3.4.
|
225
|
+
rubygems_version: 3.4.13
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: Complete, fast and testable actions for Rack and Hanami
|