Sha256: 3fc4b329d33919af396589692eb0f7b3375b097a91bec67697d6969e5ee8529d

Contents?: true

Size: 577 Bytes

Versions: 26

Compression:

Stored size: 577 Bytes

Contents

require 'rack'

module Rack

  module Rewritten

    class Subdomain

      def initialize(app, *fqdns)
        @app = app
        @fqdns = fqdns
      end

      def call(env)
        puts "-> Rack::Rewritten::Subdomain"
        req = Rack::Request.new(env)

        @fqdns.each do |n|
          if req.host =~ /(.+)\.#{n}$/
            if $1 == 'www'
              break
            else
              env["SUBDOMAIN"] = $1
              env["FQDN"] = n 
              break
            end
          end
        end

        @app.call(env) 
      end

    end

  end

end


Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
rewritten-0.15.2 lib/rack/subdomain.rb
rewritten-0.15.1 lib/rack/subdomain.rb
rewritten-0.15.0 lib/rack/subdomain.rb
rewritten-0.14.2 lib/rack/subdomain.rb
rewritten-0.14.1 lib/rack/subdomain.rb
rewritten-0.14.0 lib/rack/subdomain.rb
rewritten-0.13.1 lib/rack/subdomain.rb
rewritten-0.13.0 lib/rack/subdomain.rb
rewritten-0.12.1 lib/rack/subdomain.rb
rewritten-0.12.0 lib/rack/subdomain.rb
rewritten-0.11.1 lib/rack/subdomain.rb
rewritten-0.11.0 lib/rack/subdomain.rb
rewritten-0.10.0 lib/rack/subdomain.rb
rewritten-0.9.1 lib/rack/subdomain.rb
rewritten-0.9.0 lib/rack/subdomain.rb
rewritten-0.8.2 lib/rack/subdomain.rb
rewritten-0.8.1 lib/rack/subdomain.rb
rewritten-0.8.0 lib/rack/subdomain.rb
rewritten-0.7.0 lib/rack/subdomain.rb
rewritten-0.6.0 lib/rack/subdomain.rb