Files
discourse/lib/middleware/apply_cdn.rb
Régis Hanol bb0c2813ac FEATURE: generate (avatar) thumbnails in a background task
FIX: keep the "uploading..." indicator until the server replies via the MessageBus
FIX: text was disapearing when uploading an avatar

PERF: always use a region for S3 (defaults to 'us-east-1')
FEATURE: ApplyCDN middleware when using S3
FIX: use the same pattern to store files on S3 and locally
PERF: keep a local cache of uploads when generating thumbnails
FEATURE: migrate_to_s3 rake task
2015-05-25 17:59:00 +02:00

25 lines
536 B
Ruby

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