Class: Mailscope::AssetsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Mailscope::AssetsController
- Defined in:
- app/controllers/mailscope/assets_controller.rb
Overview
Serves the engine's own CSS/JS from disk with an immutable cache header. This keeps API-only apps working without an asset pipeline, and avoids letter_opener_web's habit of inlining ~277 KB of vendor code into every single HTML response.
Constant Summary collapse
- ROOT =
Mailscope::Engine.root.join('app', 'assets', 'mailscope')
- TYPES =
{ '.css' => 'text/css', '.js' => 'text/javascript', '.svg' => 'image/svg+xml', '.woff2' => 'font/woff2' }.freeze
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/controllers/mailscope/assets_controller.rb', line 15 def show path = ROOT.join(File.basename(params[:file])).cleanpath return head :not_found unless path.to_s.start_with?("#{ROOT}/") && path.file? response.headers['Cache-Control'] = 'public, max-age=31536000, immutable' send_file path, type: TYPES.fetch(path.extname, 'application/octet-stream'), disposition: 'inline' end |