Sha256: 4e39549aa6e31ba9cf289d25b6a72179709db567dfe4f2458813801bb73c7401
Contents?: true
Size: 603 Bytes
Versions: 6
Compression:
Stored size: 603 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 Regexp.last_match(1) == 'www' break else env['SUBDOMAIN'] = Regexp.last_match(1) env['FQDN'] = n break end end end @app.call(env) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems