Class: MapDevTools::StaticMiddleware
- Inherits:
-
Object
- Object
- MapDevTools::StaticMiddleware
- Defined in:
- lib/map_dev_tools.rb
Overview
Rack middleware for serving static JS files from gem
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ StaticMiddleware
constructor
A new instance of StaticMiddleware.
Constructor Details
#initialize(app) ⇒ StaticMiddleware
Returns a new instance of StaticMiddleware.
15 16 17 18 |
# File 'lib/map_dev_tools.rb', line 15 def initialize(app) @app = app @gem_public_path = File.('map_dev_tools/public', __dir__) end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/map_dev_tools.rb', line 20 def call(env) request = Rack::Request.new(env) if request.path.match?(%r{^/js/}) serve_js_file(request.path) else @app.call(env) end end |