Class: Cubic::Static
- Inherits:
-
Object
- Object
- Cubic::Static
- Defined in:
- lib/cubic/middleware/static.rb
Overview
Replaces the Rack::Static module as was unreliable for this application.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Static
constructor
A new instance of Static.
- #valid_route(path) ⇒ Object
Constructor Details
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/cubic/middleware/static.rb', line 9 def call(env) if valid_route(env['PATH_INFO']) @file.call(env) else @app.call(env) end end |
#valid_route(path) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/cubic/middleware/static.rb', line 25 def valid_route(path) if @url.is_a? Array ar = @url.map { |u| path.include?(u) ? true : false } ar.include? true else path.include?(@url) ? true : false end end |