Sha256: 506fc2e9bda428897b5017d9f2bd4e5eba328f231e4f2e2ef4ace833b7386500

Contents?: true

Size: 780 Bytes

Versions: 13

Compression:

Stored size: 780 Bytes

Contents

name 'http responder'
always_start true

default[:host], default[:port] = Kurchatov::Config[:http_responder].to_s.split(":")

run_if do
  !!Kurchatov::Config[:http_responder]
end

helpers do
  @s_time = Time.now
  def json_info
    {
      :version => Kurchatov::VERSION,
      :uptime => (Time.now - @s_time).to_i,
      :monitor => monitor.inspect,
    }.to_json + "\n"
  end
end

run do
  @server ||= TCPServer.new(plugin.host, plugin.port)
  loop do
    client = @server.accept
    response = json_info
    client.gets
    headers = "HTTP/1.1 200 OK\r\n" +
      "Server: Kurchatov Ruby\r\n" +
      "Content-Length: #{response.bytesize}\r\n" +
      "Content-Type: application/json\r\n\r\n"
      client.print headers
      client.print response
      client.close
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kurchatov-0.1.7 lib/kurchatov/responders/http.rb
kurchatov-0.1.6 lib/kurchatov/responders/http.rb
kurchatov-0.1.5 lib/kurchatov/responders/http.rb
kurchatov-0.1.4 lib/kurchatov/responders/http.rb
kurchatov-0.1.3 lib/kurchatov/responders/http.rb
kurchatov-0.1.2 lib/kurchatov/responders/http.rb
kurchatov-0.1.1 lib/kurchatov/responders/http.rb
kurchatov-0.1.0 lib/kurchatov/responders/http.rb
kurchatov-0.0.9 lib/kurchatov/responders/http.rb
kurchatov-0.0.8.pre.3 lib/kurchatov/responders/http.rb
kurchatov-0.0.7.pre.4 lib/kurchatov/responders/http.rb
kurchatov-0.0.8.pre.2 lib/kurchatov/responders/http.rb
kurchatov-0.0.8.pre.1 lib/kurchatov/responders/http.rb