Class: E20::Ops::Middleware::HostnameMiddleware
- Inherits:
-
Object
- Object
- E20::Ops::Middleware::HostnameMiddleware
- Defined in:
- lib/e20/ops/middleware/hostname_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ HostnameMiddleware
constructor
A new instance of HostnameMiddleware.
Constructor Details
#initialize(app, options = {}) ⇒ HostnameMiddleware
Returns a new instance of HostnameMiddleware.
6 7 8 9 10 11 12 13 |
# File 'lib/e20/ops/middleware/hostname_middleware.rb', line 6 def initialize(app, = {}) @app = app @hostname = [:hostname] || Hostname.new if (logger = [:logger]) logger.info "[#{self.class.name}] Running on: #{@hostname}" end end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 |
# File 'lib/e20/ops/middleware/hostname_middleware.rb', line 15 def call(env) status, headers, body = @app.call(env) headers["X-Served-By"] = @hostname.to_s [status, headers, body] end |