Sha256: f8d1200c7859a0dc153e69c8ce7a912645031aae65a2fef3a028af03ddd05221

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

# rails 3.1+
if defined?(Rails::Railtie)
  module SecureHeaders
    class Railtie < Rails::Engine
      isolate_namespace ::SecureHeaders if defined? isolate_namespace # rails 3.0
      initializer "secure_headers.action_controller" do
        ActiveSupport.on_load(:action_controller) do
          include ::SecureHeaders
        end
      end
    end
  end
else
  module ActionController
    class Base
      include ::SecureHeaders
    end
  end

  module SecureHeaders
    module Routing
      module MapperExtensions
        def csp_endpoint
          @set.add_route(ContentSecurityPolicy::FF_CSP_ENDPOINT, {:controller => "content_security_policy", :action => "scribe"})
        end
      end
    end
  end

  if defined?(ActiveSupport::Dependencies)
    if ActiveSupport::Dependencies.autoload_paths
      ActiveSupport::Dependencies.autoload_paths << File.expand_path(File.join("..", "..", "..", "app", "controllers"), __FILE__)
    else
      ActiveSupport::Dependencies.autoload_paths = [File.expand_path(File.join("..", "..", "..", "app", "controllers"), __FILE__)]
    end
  end

  if defined? ActionController::Routing
    ActionController::Routing::RouteSet::Mapper.send :include, ::SecureHeaders::Routing::MapperExtensions
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
secure_headers-1.4.1 lib/secure_headers/railtie.rb
secure_headers-1.4.0 lib/secure_headers/railtie.rb
secure_headers-1.3.4 lib/secure_headers/railtie.rb