Class: Puma::Stats::App

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/stats/app.rb

Instance Method Summary collapse

Constructor Details

#initialize(launcher) ⇒ App

Returns a new instance of App.



8
9
10
11
# File 'lib/puma/stats/app.rb', line 8

def initialize(launcher)
  @launcher = launcher
  @auth_token = launcher.options[:stats_token]
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/puma/stats/app.rb', line 13

def call(env)
  return rack_response(403, 'Invalid stats auth token', 'text/plain') unless authenticate(env)

  case env['PATH_INFO']
  when %r{/puma-stats-gc$}
    rack_response(200, GC.stat.to_json)

  when %r{/puma-stats$}
    rack_response(200, @launcher.stats)

  else
    rack_response 404, 'Unsupported request', 'text/plain'
  end
end