Class: Hanami::Components::App::Controller Private
- Inherits:
-
Object
- Object
- Hanami::Components::App::Controller
- Defined in:
- lib/hanami/components/app/controller.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
hanami-controller configuration for a sigle Hanami application in the project.
Constant Summary collapse
- STRICT_TRANSPORT_SECURITY_HEADER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'Strict-Transport-Security'.freeze
- STRICT_TRANSPORT_SECURITY_DEFAULT_VALUE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'max-age=31536000'.freeze
Class Method Summary collapse
-
.resolve(app) ⇒ Object
private
Configure hanami-controller for a single Hanami application in the project.
Class Method Details
.resolve(app) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configure hanami-controller for a single Hanami application in the project.
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hanami/components/app/controller.rb', line 24 def self.resolve(app) config = app.configuration namespace = app.namespace unless namespace.const_defined?('Controller', false) controller = Hanami::Controller.duplicate(namespace) do handle_exceptions config.handle_exceptions default_request_format config.default_request_format default_response_format config.default_response_format default_headers( Hanami::Config::Security::X_FRAME_OPTIONS_HEADER => config.security., Hanami::Config::Security::X_CONTENT_TYPE_OPTIONS_HEADER => config.security., Hanami::Config::Security::X_XSS_PROTECTION_HEADER => config.security.x_xss_protection, Hanami::Config::Security::CONTENT_SECURITY_POLICY_HEADER => config.security.content_security_policy ) default_headers[STRICT_TRANSPORT_SECURITY_HEADER] = STRICT_TRANSPORT_SECURITY_DEFAULT_VALUE if config.force_ssl if config..enabled? require 'hanami/action/cookies' prepare { include Hanami::Action::Cookies } config.. end if config.sessions.enabled? prepare do include Hanami::Action::Session include Hanami::Action::CSRFProtection end end prepare { include Hanami::Action::RoutingHelpers } config.controller.__apply(self) end namespace.const_set('Controller', controller) end Components.resolved "#{app.app_name}.controller", namespace.const_get('Controller').configuration end |