Class: Itiscold::WebServer::SampleServlet

Inherits:
TTYServlet
  • Object
show all
Defined in:
lib/itiscold.rb

Instance Method Summary collapse

Methods inherited from TTYServlet

#initialize

Constructor Details

This class inherits a constructor from Itiscold::WebServer::TTYServlet

Instance Method Details

#do_GET(request, response) ⇒ Object



346
347
348
349
350
351
352
353
354
# File 'lib/itiscold.rb', line 346

def do_GET request, response
  response.status = 200
  response['Content-Type'] = 'text/json'
  @mutex.synchronize do
    response.body = JSON.dump @tty.samples.map { |s|
      { time: s.first.iso8601, temp: s.last }
    }
  end
end