Class: Leafy::Rack::Admin
- Inherits:
-
Object
- Object
- Leafy::Rack::Admin
- Defined in:
- lib/leafy/rack/admin.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, metrics_registry, health_registry, path = '/admin') ⇒ Admin
constructor
A new instance of Admin.
Constructor Details
#initialize(app, metrics_registry, health_registry, path = '/admin') ⇒ Admin
Returns a new instance of Admin.
35 36 37 38 39 40 |
# File 'lib/leafy/rack/admin.rb', line 35 def initialize(app, metrics_registry, health_registry, path = '/admin') @app = app @path = path @metrics = metrics_registry @health = health_registry end |
Class Method Details
.response(path) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/leafy/rack/admin.rb', line 10 def self.response( path ) [ 200, { 'Content-Type' => 'text/html' }, [ <<EOF <DOCTYPE html> <html> <head> <title>metrics</title> </head> <body> <h1>menu</h1> <ul> <li><a href='#{path}/metrics'>metrics</a> (<a href='#{path}/metrics?pretty'>pretty</a>)</li> <li><a href='#{path}/health'>health</a> (<a href='#{path}/health?pretty'>pretty</a>)</li> <li><a href='#{path}/ping'>ping</a></li> <li><a href='#{path}/threads'>thread-dump</a></li> </ul> </body> </html> EOF ] ] end |
Instance Method Details
#call(env) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/leafy/rack/admin.rb', line 42 def call(env) if ( path = env['PATH_INFO'] ).start_with? @path dispatch( path.sub( /#{@path}/, ''), env ) else @app.call( env ) end end |