Class: IsolateAssets::Controller

Inherits:
ActionController::API
  • Object
show all
Includes:
ActionController::MimeResponds
Defined in:
lib/isolate_assets/controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/isolate_assets/controller.rb', line 9

def show
  file_path = safe_file_path

  if file_path && File.exist?(file_path)
    expires_in 1.year, public: true
    fresh_when(etag: File.mtime(file_path), public: true)

    send_file file_path,
      type: content_type,
      disposition: "inline"
  else
    head :not_found
  end
end