Class: HotReloadProxy::Proxy
- Inherits:
-
Rack::Proxy
- Object
- Rack::Proxy
- HotReloadProxy::Proxy
- Defined in:
- lib/hot_reload_proxy/proxy.rb
Constant Summary collapse
- WEBPACK_HOT_RELOAD_FILE_PATTERN =
'.hot-update.'
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Proxy
constructor
A new instance of Proxy.
- #proxy?(env) ⇒ Boolean
- #rewrite_env(env) ⇒ Object
Constructor Details
#initialize(app) ⇒ Proxy
Returns a new instance of Proxy.
7 8 9 |
# File 'lib/hot_reload_proxy/proxy.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 |
# File 'lib/hot_reload_proxy/proxy.rb', line 11 def call(env) # call super if we want to proxy (proxy?(env) && super) || @app.call(env) end |
#proxy?(env) ⇒ Boolean
16 17 18 |
# File 'lib/hot_reload_proxy/proxy.rb', line 16 def proxy?(env) Rack::Request.new(env).path.include?(WEBPACK_HOT_RELOAD_FILE_PATTERN) end |
#rewrite_env(env) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/hot_reload_proxy/proxy.rb', line 20 def rewrite_env(env) host = HotReloadProxy::Config.host port = HotReloadProxy::Config.port env['HTTP_HOST'] = "#{host}:#{port}" env end |