FEATURE: allow users to pick a CDN for s3 assets

This commit is contained in:
Sam
2015-05-26 11:13:12 +10:00
parent b9c7e3b74a
commit 90eaad336d
6 changed files with 37 additions and 33 deletions

View File

@ -1,24 +0,0 @@
module Middleware
class ApplyCDN
def initialize(app, settings={})
@app = app
end
def call(env)
status, headers, response = @app.call(env)
if Discourse.asset_host.present? &&
Discourse.store.external? &&
(headers["Content-Type"].start_with?("text/") ||
headers["Content-Type"].start_with?("application/json"))
response.body = response.body.gsub(Discourse.store.absolute_base_url, Discourse.asset_host)
end
[status, headers, response]
end
end
end