Sha256: da85f56ea9e6ebd51e433bd3620ed1fc7c0307148914f3a5ade8f293404d79b8

Contents?: true

Size: 589 Bytes

Versions: 4

Compression:

Stored size: 589 Bytes

Contents

# coding:us-ascii
require 'rack'

module GyomuRuby
  module OrdinarySystemDevelopment
    class AllYourSiteAreBelongToSsl
      def initialize(app)
        @app = app
      end

      def call(env)
        if env['HTTPS'] == 'on' || env['HTTP_X_FORWARDED_PROTO'] == 'https'
          @app.call(env)
        else
          url = Rack::Request.new(env).url.sub(/^http:/, 'https:')
          body = "<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>"
          [301, {'Location' => url, 'Content-Type' => 'text/html'}, [body]]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gyomu_ruby-0.0.5 lib/gyomu_ruby/ordinary_system_development/all_your_site_are_belong_to_ssl.rb
gyomu_ruby-0.0.4 lib/gyomu_ruby/ordinary_system_development/all_your_site_are_belong_to_ssl.rb
gyomu_ruby-0.0.2 lib/gyomu_ruby/ordinary_system_development/all_your_site_are_belong_to_ssl.rb
gyomu_ruby-0.0.1 lib/gyomu_ruby/ordinary_system_development/all_your_site_are_belong_to_ssl.rb