Class: Telm::AssetsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Telm::AssetsController
- Defined in:
- app/controllers/telm/assets_controller.rb
Overview
Serves the compiled Dimsum distribution straight from the gem, bypassing host asset pipelines entirely. Filenames are content-hashed, so responses are immutable-cacheable forever.
Constant Summary collapse
- CONTENT_TYPES =
{ ".css" => "text/css", ".js" => "text/javascript", ".woff2" => "font/woff2" }.freeze
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/telm/assets_controller.rb', line 24 def show filename = params[:filename] return head :not_found unless Telm::Assets.include?(filename) expires_in 1.year, public: true # :extras works verbatim on every supported Rails; the :immutable # option only exists from 8.0. response.cache_control[:extras] = ["immutable"] send_file Telm::Assets.root.join(filename), type: CONTENT_TYPES.fetch(File.extname(filename)), disposition: "inline" end |