hanami-controller 2.0.0.alpha2 → 2.0.0.alpha6
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 +26 -0
- data/README.md +8 -6
- data/hanami-controller.gemspec +3 -2
- data/lib/hanami/action/application_action.rb +41 -21
- data/lib/hanami/action/application_configuration/content_security_policy.rb +118 -0
- data/lib/hanami/action/application_configuration.rb +22 -24
- data/lib/hanami/action/configuration.rb +12 -14
- data/lib/hanami/action/mime.rb +1 -0
- data/lib/hanami/action/response.rb +1 -1
- data/lib/hanami/action/standalone_action.rb +1 -4
- data/lib/hanami/controller/version.rb +1 -1
- data/lib/hanami/http/status.rb +1 -17
- metadata +15 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f14c59426ea7017dc546100e0443d17d5f63362cd4b6f1546adfb18ae6bd4e3
|
|
4
|
+
data.tar.gz: 62fafda341ad801430ab2575df6a28b6a9848a71739c977e481fe8fa00dbadfc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a51c5a37c6961bff7d1c3c30906cc2e072029e6d0b4ec5782ef92d592ed4f8b247807b9aabd803004afb31fd2f23900bb8a34c9d29bc1515e30e0caba4b3318a
|
|
7
|
+
data.tar.gz: b69d515d608fbaf545e7d2d4e6d19fbd6d305bc10bcc0a2208dc6e740389eb7188514112028d02dd3d8e6729192eed95305b7ec3a09cdd77039b55ac5d054083
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
# Hanami::Controller
|
|
2
2
|
Complete, fast and testable actions for Rack
|
|
3
3
|
|
|
4
|
+
## v2.0.0.alpha6 - 2022-02-10
|
|
5
|
+
### Added
|
|
6
|
+
- [Luca Guidi] Official support for Ruby: MRI 3.1
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- [Luca Guidi] Drop support for Ruby: MRI 2.6, and 2.7.
|
|
10
|
+
- [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`.
|
|
11
|
+
|
|
12
|
+
## v2.0.0.alpha5 - 2022-01-12
|
|
13
|
+
### Added
|
|
14
|
+
- [Philip Arndt] Added "rss" ("application/rss+xml") to list of supported MIME types
|
|
15
|
+
|
|
16
|
+
## v2.0.0.alpha4 - 2021-12-07
|
|
17
|
+
### Added
|
|
18
|
+
- [Luca Guidi] Manage Content Security Policy (CSP) defaults and new API via `Hanami::Action::ApplicationConfiguration#content_security_policy`
|
|
19
|
+
- [Tim Riley & Marc Busqué] Provide access to routes inside all application actions via `Hanami::Action::ApplicationAction#routes`
|
|
20
|
+
|
|
21
|
+
## v2.0.0.alpha3 - 2021-11-09
|
|
22
|
+
### Added
|
|
23
|
+
- [Luca Guidi] Automatically include session behavior in `Hanami::Action` when sessions are enabled via Hanami application config
|
|
24
|
+
- [Sean Collins] Pass exposures from action to view
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- [Tim Riley] (Internal) Updated settings to use updated `setting` API in dry-configurable 0.13.0
|
|
28
|
+
- [Sean Collins] Move automatic view rendering from `handle` to `finish`
|
|
29
|
+
|
|
4
30
|
## v2.0.0.alpha2 - 2021-05-04
|
|
5
31
|
### Added
|
|
6
32
|
- [Luca Guidi] Official support for Ruby: MRI 3.0
|
data/README.md
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Complete, fast and testable actions for Rack and [Hanami](http://hanamirb.org)
|
|
4
4
|
|
|
5
|
+
## Version
|
|
6
|
+
|
|
7
|
+
**This branch contains the code for `hanami-controller` 2.x.**
|
|
8
|
+
|
|
5
9
|
## Status
|
|
6
10
|
|
|
7
11
|
[](https://badge.fury.io/rb/hanami-controller)
|
|
8
|
-
[](https://github.com/hanami/controller/actions?query=workflow%3Aci+branch%3Amain)
|
|
13
|
+
[](https://codecov.io/gh/hanami/controller)
|
|
10
14
|
[](https://depfu.com/github/hanami/controller?project=Bundler)
|
|
11
15
|
[](http://inch-ci.org/github/hanami/controller)
|
|
12
16
|
|
|
@@ -22,7 +26,7 @@ Complete, fast and testable actions for Rack and [Hanami](http://hanamirb.org)
|
|
|
22
26
|
|
|
23
27
|
## Rubies
|
|
24
28
|
|
|
25
|
-
__Hanami::Controller__ supports Ruby (MRI)
|
|
29
|
+
__Hanami::Controller__ supports Ruby (MRI) 3.0+
|
|
26
30
|
|
|
27
31
|
## Installation
|
|
28
32
|
|
|
@@ -963,6 +967,4 @@ __Hanami::Controller__ uses [Semantic Versioning 2.0.0](http://semver.org)
|
|
|
963
967
|
|
|
964
968
|
## Copyright
|
|
965
969
|
|
|
966
|
-
Copyright © 2014-
|
|
967
|
-
|
|
968
|
-
This project was formerly known as Lotus (`lotus-controller`).
|
|
970
|
+
Copyright © 2014-2022 Hanami Team – Released under MIT License
|
data/hanami-controller.gemspec
CHANGED
|
@@ -17,11 +17,12 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.executables = []
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(spec)/})
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
|
-
spec.
|
|
20
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
21
|
+
spec.required_ruby_version = '>= 3.0'
|
|
21
22
|
|
|
22
23
|
spec.add_dependency 'rack', '~> 2.0'
|
|
23
24
|
spec.add_dependency 'hanami-utils', '~> 2.0.alpha'
|
|
24
|
-
spec.add_dependency 'dry-configurable', '~> 0.
|
|
25
|
+
spec.add_dependency 'dry-configurable', '~> 0.13', '>= 0.13.0'
|
|
25
26
|
|
|
26
27
|
spec.add_development_dependency 'bundler', '>= 1.6', '< 3'
|
|
27
28
|
spec.add_development_dependency 'rack-test', '~> 1.0'
|
|
@@ -14,7 +14,7 @@ module Hanami
|
|
|
14
14
|
def included(action_class)
|
|
15
15
|
action_class.include InstanceMethods
|
|
16
16
|
|
|
17
|
-
define_initialize
|
|
17
|
+
define_initialize
|
|
18
18
|
configure_action action_class
|
|
19
19
|
extend_behavior action_class
|
|
20
20
|
end
|
|
@@ -25,20 +25,33 @@ module Hanami
|
|
|
25
25
|
|
|
26
26
|
private
|
|
27
27
|
|
|
28
|
-
def define_initialize
|
|
28
|
+
def define_initialize
|
|
29
29
|
resolve_view = method(:resolve_paired_view)
|
|
30
30
|
resolve_context = method(:resolve_view_context)
|
|
31
|
+
resolve_routes = method(:resolve_routes)
|
|
31
32
|
|
|
32
33
|
define_method :initialize do |**deps|
|
|
33
34
|
# Conditionally assign these to repsect any explictly auto-injected
|
|
34
35
|
# dependencies provided by the class
|
|
35
36
|
@view ||= deps[:view] || resolve_view.(self.class)
|
|
36
37
|
@view_context ||= deps[:view_context] || resolve_context.()
|
|
38
|
+
@routes ||= deps[:routes] || resolve_routes.()
|
|
37
39
|
|
|
38
40
|
super(**deps)
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
|
|
44
|
+
def resolve_paired_view(action_class)
|
|
45
|
+
view_identifiers = application.config.actions.view_name_inferrer.(
|
|
46
|
+
action_name: action_class.name,
|
|
47
|
+
provider: provider
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
view_identifiers.detect { |identifier|
|
|
51
|
+
break provider[identifier] if provider.key?(identifier)
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
42
55
|
def resolve_view_context
|
|
43
56
|
identifier = application.config.actions.view_context_identifier
|
|
44
57
|
|
|
@@ -49,15 +62,8 @@ module Hanami
|
|
|
49
62
|
end
|
|
50
63
|
end
|
|
51
64
|
|
|
52
|
-
def
|
|
53
|
-
|
|
54
|
-
action_name: action_class.name,
|
|
55
|
-
provider: provider
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
view_identifiers.detect { |identifier|
|
|
59
|
-
break provider[identifier] if provider.key?(identifier)
|
|
60
|
-
}
|
|
65
|
+
def resolve_routes
|
|
66
|
+
application[:routes_helper] if application.key?(:routes_helper)
|
|
61
67
|
end
|
|
62
68
|
|
|
63
69
|
def configure_action(action_class)
|
|
@@ -68,6 +74,11 @@ module Hanami
|
|
|
68
74
|
end
|
|
69
75
|
|
|
70
76
|
def extend_behavior(action_class)
|
|
77
|
+
if application.config.actions.sessions.enabled?
|
|
78
|
+
require "hanami/action/session"
|
|
79
|
+
action_class.include Hanami::Action::Session
|
|
80
|
+
end
|
|
81
|
+
|
|
71
82
|
if application.config.actions.csrf_protection
|
|
72
83
|
require "hanami/action/csrf_protection"
|
|
73
84
|
action_class.include Hanami::Action::CSRFProtection
|
|
@@ -82,16 +93,7 @@ module Hanami
|
|
|
82
93
|
module InstanceMethods
|
|
83
94
|
attr_reader :view
|
|
84
95
|
attr_reader :view_context
|
|
85
|
-
|
|
86
|
-
protected
|
|
87
|
-
|
|
88
|
-
def handle(request, response)
|
|
89
|
-
if view
|
|
90
|
-
response.render view, **request.params
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
private
|
|
96
|
+
attr_reader :routes
|
|
95
97
|
|
|
96
98
|
def build_response(**options)
|
|
97
99
|
options = options.merge(view_options: method(:view_options))
|
|
@@ -105,6 +107,24 @@ module Hanami
|
|
|
105
107
|
def view_context_options(req, res)
|
|
106
108
|
{request: req, response: res}
|
|
107
109
|
end
|
|
110
|
+
|
|
111
|
+
def finish(req, res, halted)
|
|
112
|
+
res.render(view, **req.params) if render?(res)
|
|
113
|
+
super
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Decide whether to render the current response with the associated view.
|
|
117
|
+
# This can be overridden to enable/disable automatic rendering.
|
|
118
|
+
#
|
|
119
|
+
# @param res [Hanami::Action::Response]
|
|
120
|
+
#
|
|
121
|
+
# @return [TrueClass,FalseClass]
|
|
122
|
+
#
|
|
123
|
+
# @since 2.0.0
|
|
124
|
+
# @api public
|
|
125
|
+
def render?(res)
|
|
126
|
+
view && res.body.empty?
|
|
127
|
+
end
|
|
108
128
|
end
|
|
109
129
|
end
|
|
110
130
|
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hanami
|
|
4
|
+
class Action
|
|
5
|
+
class ApplicationConfiguration
|
|
6
|
+
# Configuration for Content Security Policy in Hanami applications
|
|
7
|
+
#
|
|
8
|
+
# @since 2.0.0
|
|
9
|
+
class ContentSecurityPolicy
|
|
10
|
+
# @since 2.0.0
|
|
11
|
+
# @api private
|
|
12
|
+
def initialize(&blk)
|
|
13
|
+
@policy = {
|
|
14
|
+
base_uri: "'self'",
|
|
15
|
+
child_src: "'self'",
|
|
16
|
+
connect_src: "'self'",
|
|
17
|
+
default_src: "'none'",
|
|
18
|
+
font_src: "'self'",
|
|
19
|
+
form_action: "'self'",
|
|
20
|
+
frame_ancestors: "'self'",
|
|
21
|
+
frame_src: "'self'",
|
|
22
|
+
img_src: "'self' https: data:",
|
|
23
|
+
media_src: "'self'",
|
|
24
|
+
object_src: "'none'",
|
|
25
|
+
plugin_types: "application/pdf",
|
|
26
|
+
script_src: "'self'",
|
|
27
|
+
style_src: "'self' 'unsafe-inline' https:"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
blk&.(self)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @since 2.0.0
|
|
34
|
+
# @api private
|
|
35
|
+
def initialize_copy(original_object)
|
|
36
|
+
@policy = original_object.instance_variable_get(:@policy).dup
|
|
37
|
+
super
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Get a CSP setting
|
|
41
|
+
#
|
|
42
|
+
# @param key [Symbol] the underscored name of the CPS setting
|
|
43
|
+
# @return [String,NilClass] the CSP setting, if any
|
|
44
|
+
#
|
|
45
|
+
# @since 2.0.0
|
|
46
|
+
# @api public
|
|
47
|
+
#
|
|
48
|
+
# @example
|
|
49
|
+
# module MyApp
|
|
50
|
+
# class Application < Hanami::Application
|
|
51
|
+
# config.actions.content_security_policy[:base_uri] # => "'self'"
|
|
52
|
+
# end
|
|
53
|
+
# end
|
|
54
|
+
def [](key)
|
|
55
|
+
@policy[key]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Set a CSP setting
|
|
59
|
+
#
|
|
60
|
+
# @param key [Symbol] the underscored name of the CPS setting
|
|
61
|
+
# @param value [String] the CSP setting value
|
|
62
|
+
#
|
|
63
|
+
# @since 2.0.0
|
|
64
|
+
# @api public
|
|
65
|
+
#
|
|
66
|
+
# @example Replace a default value
|
|
67
|
+
# module MyApp
|
|
68
|
+
# class Application < Hanami::Application
|
|
69
|
+
# config.actions.content_security_policy[:plugin_types] = nil
|
|
70
|
+
# end
|
|
71
|
+
# end
|
|
72
|
+
#
|
|
73
|
+
# @example Append to a default value
|
|
74
|
+
# module MyApp
|
|
75
|
+
# class Application < Hanami::Application
|
|
76
|
+
# config.actions.content_security_policy[:script_src] += " https://my.cdn.test"
|
|
77
|
+
# end
|
|
78
|
+
# end
|
|
79
|
+
def []=(key, value)
|
|
80
|
+
@policy[key] = value
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Deletes a CSP key
|
|
84
|
+
#
|
|
85
|
+
# @param key [Symbol] the underscored name of the CPS setting
|
|
86
|
+
#
|
|
87
|
+
# @since 2.0.0
|
|
88
|
+
# @api public
|
|
89
|
+
#
|
|
90
|
+
# @example
|
|
91
|
+
# module MyApp
|
|
92
|
+
# class Application < Hanami::Application
|
|
93
|
+
# config.actions.content_security_policy.delete(:object_src)
|
|
94
|
+
# end
|
|
95
|
+
# end
|
|
96
|
+
def delete(key)
|
|
97
|
+
@policy.delete(key)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# @since 2.0.0
|
|
101
|
+
# @api private
|
|
102
|
+
def to_str
|
|
103
|
+
@policy.map do |key, value|
|
|
104
|
+
"#{dasherize(key)} #{value}"
|
|
105
|
+
end.join(";\n")
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
# @since 2.0.0
|
|
111
|
+
# @api private
|
|
112
|
+
def dasherize(key)
|
|
113
|
+
key.to_s.gsub("_", "-")
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "application_configuration/cookies"
|
|
4
4
|
require_relative "application_configuration/sessions"
|
|
5
|
+
require_relative "application_configuration/content_security_policy"
|
|
5
6
|
require_relative "configuration"
|
|
6
7
|
require_relative "view_name_inferrer"
|
|
7
8
|
|
|
@@ -10,19 +11,27 @@ module Hanami
|
|
|
10
11
|
class ApplicationConfiguration
|
|
11
12
|
include Dry::Configurable
|
|
12
13
|
|
|
13
|
-
setting
|
|
14
|
-
setting
|
|
14
|
+
setting :cookies, default: {}, constructor: -> options { Cookies.new(options) }
|
|
15
|
+
setting :sessions, constructor: proc { |storage, *options| Sessions.new(storage, *options) }
|
|
15
16
|
setting :csrf_protection
|
|
16
17
|
|
|
17
|
-
setting :name_inference_base, "actions"
|
|
18
|
-
setting :view_context_identifier, "view.context"
|
|
19
|
-
setting :view_name_inferrer, ViewNameInferrer
|
|
20
|
-
setting :view_name_inference_base, "views"
|
|
18
|
+
setting :name_inference_base, default: "actions"
|
|
19
|
+
setting :view_context_identifier, default: "view.context"
|
|
20
|
+
setting :view_name_inferrer, default: ViewNameInferrer
|
|
21
|
+
setting :view_name_inference_base, default: "views"
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
attr_accessor :content_security_policy
|
|
24
|
+
|
|
25
|
+
def initialize(*, **options)
|
|
26
|
+
super()
|
|
24
27
|
|
|
25
28
|
@base_configuration = Configuration.new
|
|
29
|
+
@content_security_policy = ContentSecurityPolicy.new do |csp|
|
|
30
|
+
if assets_server_url = options[:assets_server_url]
|
|
31
|
+
csp[:script_src] += " #{assets_server_url}"
|
|
32
|
+
csp[:style_src] += " #{assets_server_url}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
26
35
|
|
|
27
36
|
configure_defaults
|
|
28
37
|
end
|
|
@@ -31,6 +40,10 @@ module Hanami
|
|
|
31
40
|
# A nil value for `csrf_protection` means it has not been explicitly configured
|
|
32
41
|
# (neither true nor false), so we can default it to whether sessions are enabled
|
|
33
42
|
self.csrf_protection = sessions.enabled? if csrf_protection.nil?
|
|
43
|
+
|
|
44
|
+
if self.content_security_policy
|
|
45
|
+
self.default_headers["Content-Security-Policy"] = self.content_security_policy.to_str
|
|
46
|
+
end
|
|
34
47
|
end
|
|
35
48
|
|
|
36
49
|
# Returns the list of available settings
|
|
@@ -55,22 +68,7 @@ module Hanami
|
|
|
55
68
|
self.default_headers = {
|
|
56
69
|
"X-Frame-Options" => "DENY",
|
|
57
70
|
"X-Content-Type-Options" => "nosniff",
|
|
58
|
-
"X-XSS-Protection" => "1; mode=block"
|
|
59
|
-
"Content-Security-Policy" => \
|
|
60
|
-
"base-uri 'self'; " \
|
|
61
|
-
"child-src 'self'; " \
|
|
62
|
-
"connect-src 'self'; " \
|
|
63
|
-
"default-src 'none'; " \
|
|
64
|
-
"font-src 'self'; " \
|
|
65
|
-
"form-action 'self'; " \
|
|
66
|
-
"frame-ancestors 'self'; " \
|
|
67
|
-
"frame-src 'self'; " \
|
|
68
|
-
"img-src 'self' https: data:; " \
|
|
69
|
-
"media-src 'self'; " \
|
|
70
|
-
"object-src 'none'; " \
|
|
71
|
-
"plugin-types application/pdf; " \
|
|
72
|
-
"script-src 'self'; " \
|
|
73
|
-
"style-src 'self' 'unsafe-inline' https:"
|
|
71
|
+
"X-XSS-Protection" => "1; mode=block"
|
|
74
72
|
}
|
|
75
73
|
end
|
|
76
74
|
|
|
@@ -58,7 +58,7 @@ module Hanami
|
|
|
58
58
|
# @see handled_exceptions=
|
|
59
59
|
#
|
|
60
60
|
# @since 0.2.0
|
|
61
|
-
setting :handled_exceptions, {}
|
|
61
|
+
setting :handled_exceptions, default: {}
|
|
62
62
|
|
|
63
63
|
# Specifies how to handle exceptions with an HTTP status
|
|
64
64
|
#
|
|
@@ -122,7 +122,7 @@ module Hanami
|
|
|
122
122
|
# @see formats=
|
|
123
123
|
#
|
|
124
124
|
# @since 0.2.0
|
|
125
|
-
setting :formats, DEFAULT_FORMATS.dup
|
|
125
|
+
setting :formats, default: DEFAULT_FORMATS.dup
|
|
126
126
|
|
|
127
127
|
# Registers a MIME type to format mapping
|
|
128
128
|
#
|
|
@@ -211,9 +211,9 @@ module Hanami
|
|
|
211
211
|
# @see default_request_format=
|
|
212
212
|
#
|
|
213
213
|
# @since 0.5.0
|
|
214
|
-
setting :default_request_format
|
|
214
|
+
setting :default_request_format, constructor: -> format {
|
|
215
215
|
Utils::Kernel.Symbol(format) unless format.nil?
|
|
216
|
-
|
|
216
|
+
}
|
|
217
217
|
|
|
218
218
|
# @!method default_response_format=(format)
|
|
219
219
|
#
|
|
@@ -243,9 +243,9 @@ module Hanami
|
|
|
243
243
|
# @see default_request_format=
|
|
244
244
|
#
|
|
245
245
|
# @since 0.5.0
|
|
246
|
-
setting :default_response_format
|
|
246
|
+
setting :default_response_format, constructor: -> format {
|
|
247
247
|
Utils::Kernel.Symbol(format) unless format.nil?
|
|
248
|
-
|
|
248
|
+
}
|
|
249
249
|
|
|
250
250
|
# @!method default_charset=(charset)
|
|
251
251
|
#
|
|
@@ -299,9 +299,7 @@ module Hanami
|
|
|
299
299
|
# @since 0.4.0
|
|
300
300
|
#
|
|
301
301
|
# @see default_headers=
|
|
302
|
-
setting :default_headers, {}
|
|
303
|
-
headers.compact
|
|
304
|
-
end
|
|
302
|
+
setting :default_headers, default: {}, constructor: -> headers { headers.compact }
|
|
305
303
|
|
|
306
304
|
# @!method cookies=(cookie_options)
|
|
307
305
|
#
|
|
@@ -332,11 +330,11 @@ module Hanami
|
|
|
332
330
|
# @since 0.4.0
|
|
333
331
|
#
|
|
334
332
|
# @see cookies=
|
|
335
|
-
setting :cookies, {}
|
|
333
|
+
setting :cookies, default: {}, constructor: -> cookie_options {
|
|
336
334
|
# Call `to_h` here to permit `ApplicationConfiguration::Cookies` object to be
|
|
337
335
|
# provided when application actions are configured
|
|
338
336
|
cookie_options.to_h.compact
|
|
339
|
-
|
|
337
|
+
}
|
|
340
338
|
|
|
341
339
|
# @!method root_directory=(dir)
|
|
342
340
|
#
|
|
@@ -364,11 +362,11 @@ module Hanami
|
|
|
364
362
|
# @since 1.0.0
|
|
365
363
|
#
|
|
366
364
|
# @api private
|
|
367
|
-
setting :root_directory
|
|
365
|
+
setting :root_directory, constructor: -> dir {
|
|
368
366
|
dir ||= Dir.pwd
|
|
369
367
|
|
|
370
368
|
Pathname(dir).realpath
|
|
371
|
-
|
|
369
|
+
}
|
|
372
370
|
|
|
373
371
|
# Default public directory
|
|
374
372
|
#
|
|
@@ -393,7 +391,7 @@ module Hanami
|
|
|
393
391
|
#
|
|
394
392
|
# @see root_directory
|
|
395
393
|
# @see public_directory
|
|
396
|
-
setting :public_directory, DEFAULT_PUBLIC_DIRECTORY
|
|
394
|
+
setting :public_directory, default: DEFAULT_PUBLIC_DIRECTORY
|
|
397
395
|
|
|
398
396
|
# Returns the configured public directory, appended onto the root directory.
|
|
399
397
|
#
|
data/lib/hanami/action/mime.rb
CHANGED
|
@@ -553,15 +553,12 @@ module Hanami
|
|
|
553
553
|
|
|
554
554
|
# Finalize the response
|
|
555
555
|
#
|
|
556
|
-
#
|
|
557
|
-
# order to prepare their data before the response will be returned to the
|
|
558
|
-
# webserver.
|
|
556
|
+
# Prepare the data before the response will be returned to the webserver
|
|
559
557
|
#
|
|
560
558
|
# @since 0.1.0
|
|
561
559
|
# @api private
|
|
562
560
|
# @abstract
|
|
563
561
|
#
|
|
564
|
-
# @see Hanami::Action::Callable#finish
|
|
565
562
|
# @see Hanami::Action::Session#finish
|
|
566
563
|
# @see Hanami::Action::Cookies#finish
|
|
567
564
|
# @see Hanami::Action::Cache#finish
|
data/lib/hanami/http/status.rb
CHANGED
|
@@ -11,23 +11,7 @@ module Hanami
|
|
|
11
11
|
#
|
|
12
12
|
# @since 0.1.0
|
|
13
13
|
# @api private
|
|
14
|
-
ALL = ::Rack::Utils::HTTP_STATUS_CODES
|
|
15
|
-
103 => 'Checkpoint',
|
|
16
|
-
122 => 'Request-URI too long',
|
|
17
|
-
413 => 'Payload Too Large', # Rack 1.5 compat
|
|
18
|
-
414 => 'URI Too Long', # Rack 1.5 compat
|
|
19
|
-
416 => 'Range Not Satisfiable', # Rack 1.5 compat
|
|
20
|
-
418 => 'I\'m a teapot',
|
|
21
|
-
420 => 'Enhance Your Calm',
|
|
22
|
-
444 => 'No Response',
|
|
23
|
-
449 => 'Retry With',
|
|
24
|
-
450 => 'Blocked by Windows Parental Controls',
|
|
25
|
-
451 => 'Wrong Exchange server',
|
|
26
|
-
499 => 'Client Closed Request',
|
|
27
|
-
506 => 'Variant Also Negotiates', # Rack 1.5 compat
|
|
28
|
-
598 => 'Network read timeout error',
|
|
29
|
-
599 => 'Network connect timeout error'
|
|
30
|
-
}).freeze
|
|
14
|
+
ALL = ::Rack::Utils::HTTP_STATUS_CODES
|
|
31
15
|
|
|
32
16
|
# Return a status for the given code
|
|
33
17
|
#
|
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.0.
|
|
4
|
+
version: 2.0.0.alpha6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Luca Guidi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|
|
@@ -44,14 +44,20 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0.
|
|
47
|
+
version: '0.13'
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: 0.13.0
|
|
48
51
|
type: :runtime
|
|
49
52
|
prerelease: false
|
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
54
|
requirements:
|
|
52
55
|
- - "~>"
|
|
53
56
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0.
|
|
57
|
+
version: '0.13'
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 0.13.0
|
|
55
61
|
- !ruby/object:Gem::Dependency
|
|
56
62
|
name: bundler
|
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -128,6 +134,7 @@ files:
|
|
|
128
134
|
- lib/hanami/action.rb
|
|
129
135
|
- lib/hanami/action/application_action.rb
|
|
130
136
|
- lib/hanami/action/application_configuration.rb
|
|
137
|
+
- lib/hanami/action/application_configuration/content_security_policy.rb
|
|
131
138
|
- lib/hanami/action/application_configuration/cookies.rb
|
|
132
139
|
- lib/hanami/action/application_configuration/sessions.rb
|
|
133
140
|
- lib/hanami/action/base_params.rb
|
|
@@ -159,7 +166,8 @@ files:
|
|
|
159
166
|
homepage: http://hanamirb.org
|
|
160
167
|
licenses:
|
|
161
168
|
- MIT
|
|
162
|
-
metadata:
|
|
169
|
+
metadata:
|
|
170
|
+
rubygems_mfa_required: 'true'
|
|
163
171
|
post_install_message:
|
|
164
172
|
rdoc_options: []
|
|
165
173
|
require_paths:
|
|
@@ -168,14 +176,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
168
176
|
requirements:
|
|
169
177
|
- - ">="
|
|
170
178
|
- !ruby/object:Gem::Version
|
|
171
|
-
version:
|
|
179
|
+
version: '3.0'
|
|
172
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
181
|
requirements:
|
|
174
182
|
- - ">"
|
|
175
183
|
- !ruby/object:Gem::Version
|
|
176
184
|
version: 1.3.1
|
|
177
185
|
requirements: []
|
|
178
|
-
rubygems_version: 3.
|
|
186
|
+
rubygems_version: 3.3.3
|
|
179
187
|
signing_key:
|
|
180
188
|
specification_version: 4
|
|
181
189
|
summary: Complete, fast and testable actions for Rack and Hanami
|