Class: Lotus::Static
- Inherits:
-
Rack::Static
- Object
- Rack::Static
- Lotus::Static
- Defined in:
- lib/lotus/static.rb
Overview
Constant Summary collapse
- PATH_INFO =
'PATH_INFO'.freeze
- PUBLIC_DIRECTORY =
Lotus.public_directory.join('**', '*').to_s.freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Static
constructor
A new instance of Static.
Constructor Details
#initialize(app) ⇒ Static
Returns a new instance of Static.
9 10 11 12 |
# File 'lib/lotus/static.rb', line 9 def initialize(app) super(app, root: Lotus.public_directory, header_rules: _header_rules) @sources = _sources_from_applications end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lotus/static.rb', line 14 def call(env) path = env[PATH_INFO] prefix, config = @sources.find {|p, _| path.start_with?(p) } original = if prefix && config config.sources.find(path.sub(prefix, '')) end if can_serve(path, original) super else precompile(original, config) ? call(env) : @app.call(env) end end |