mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: rudimentary view tracking wired in
This commit is contained in:
parent
e105f0965c
commit
c150c55e2d
3 changed files with 65 additions and 8 deletions
|
@ -158,15 +158,20 @@ module RailsMultisite
|
|||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
def self.host(env)
|
||||
request = Rack::Request.new(env)
|
||||
request['__ws'] || request.host
|
||||
end
|
||||
|
||||
def call(env)
|
||||
host = self.class.host(env)
|
||||
begin
|
||||
|
||||
#TODO: add a callback so users can simply go to a domain to register it, or something
|
||||
return [404, {}, ["not found"]] unless @@host_spec_cache[request.host]
|
||||
return [404, {}, ["not found"]] unless @@host_spec_cache[host]
|
||||
|
||||
ActiveRecord::Base.connection_handler.clear_active_connections!
|
||||
self.class.establish_connection(:host => request['__ws'] || request.host)
|
||||
self.class.establish_connection(:host => host)
|
||||
@app.call(env)
|
||||
ensure
|
||||
ActiveRecord::Base.connection_handler.clear_active_connections!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue