Class: Julewire::Rails::DoctorApp

Inherits:
Object
  • Object
show all
Defined in:
lib/julewire/rails/doctor_app.rb

Constant Summary collapse

CONTENT_TYPE =
{ "content-type" => "text/html; charset=utf-8" }.freeze
JSON_TYPE =
{ "content-type" => "application/json; charset=utf-8" }.freeze
SSE_TYPE =
{
  "cache-control" => "no-cache",
  "content-type" => "text/event-stream; charset=utf-8"
}.freeze
TAIL_LIMIT =
50

Instance Method Summary collapse

Constructor Details

#initialize(runtime: Julewire, tail: nil) ⇒ DoctorApp

Returns a new instance of DoctorApp.



19
20
21
22
# File 'lib/julewire/rails/doctor_app.rb', line 19

def initialize(runtime: Julewire, tail: nil)
  @runtime = runtime
  @tail = tail
end

Instance Method Details

#call(env) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/julewire/rails/doctor_app.rb', line 24

def call(env)
  request = ::Rack::Request.new(env)
  case request.path_info
  when "", "/", "/doctor"
    html_response(render_doctor(request))
  when "/doctor.json"
    json_response(@runtime.doctor)
  when "/tail"
    html_response(render_tail(request))
  when "/tail.json"
    json_response(tail_records)
  when "/tail/events"
    sse_response(tail_events(request))
  else
    not_found_response
  end
end