Class: EurekaRuby::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/eureka_ruby/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
# File 'lib/eureka_ruby/middleware.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/eureka_ruby/middleware.rb', line 9

def call(env)
  if env['PATH_INFO'] == health_path
    NewRelic::Agent.ignore_transaction if defined? NewRelic
    [200, health_headers, [health_response]]
  elsif env['PATH_INFO'] == info_path
    NewRelic::Agent.ignore_transaction if defined? NewRelic
    [200, { 'Content-Type' => 'application/json' }, [info_response.to_json]]
  else
    @app.call(env)
  end
end