mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00

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
25 lines
536 B
Ruby
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
|