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