An easy way would be to use a plugin with plugins, something like this:
class RackAssetFilter def initialize app @app = app end def call env @status, @headers, @body = @app.call env if env['PATH_INFO'].starts_with?( "/assets/" ) @headers['X-Header-1'] = 'value'
To enable it, in application.rb:
config.middleware.insert_before( ActionDispatch::Static, RackAssetFilter )
Keep in mind that you need to declare or load a RackAssetFilter with a request before pushing it onto the middleware stack in application.rb
source share