lib/hanami/loader.rb in hanami-0.7.3 vs lib/hanami/loader.rb in hanami-0.8.0

- old
+ new

@@ -11,23 +11,22 @@ # Load an application # # @since 0.1.0 # @api private class Loader + LOCK = Mutex.new STRICT_TRANSPORT_SECURITY_HEADER = 'Strict-Transport-Security'.freeze STRICT_TRANSPORT_SECURITY_DEFAULT_VALUE = 'max-age=31536000'.freeze def initialize(application) @application = application @configuration = @application.configuration - - @mutex = Mutex.new end def load! - @mutex.synchronize do + LOCK.synchronize do load_configuration! configure_frameworks! load_configuration_load_paths! load_rack! load_frameworks! @@ -57,11 +56,13 @@ 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.x_frame_options, - Hanami::Config::Security::CONTENT_SECURITY_POLICY_HEADER => config.security.content_security_policy + Hanami::Config::Security::X_CONTENT_TYPE_OPTIONS_HEADER => config.security.x_content_type_options, + 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.merge!(STRICT_TRANSPORT_SECURITY_HEADER => STRICT_TRANSPORT_SECURITY_DEFAULT_VALUE) if config.force_ssl if config.cookies.enabled? require 'hanami/action/cookies' @@ -141,14 +142,12 @@ end end def _configure_logger! unless application_module.const_defined?('Logger', false) - if configuration.logger.nil? - configuration.logger Hanami::Logger.new(application_module.to_s) - end - application_module.const_set('Logger', configuration.logger) + configuration.logger.app_name(application_module.to_s) + application_module.const_set('Logger', configuration.logger.build) end end def load_frameworks! _load_view_framework! @@ -248,10 +247,10 @@ def namespace configuration.namespace || application_module end def load_initializers! - Dir["#{configuration.root}/config/initializers/**/*.rb"].each do |file| + Dir["#{configuration.root}/config/initializers/**/*.rb"].sort.each do |file| require file end end end end