Sha256: cf82253758306dbf94804cbd84448e7096477267d1898a1ab09bc46b95380514
Contents?: true
Size: 908 Bytes
Versions: 13
Compression:
Stored size: 908 Bytes
Contents
module Kurchatov module Responders class Http < Kurchatov::Plugin def initialize(conn) @host, @port = conn.split(':') @name = "http server #{@host}:#{@port}" @s_time = Time.now end def run @server ||= TCPServer.new(@host, @port) loop do client = @server.accept response = 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 def info { :version => Kurchatov::VERSION, :uptime => (Time.now - @s_time).to_i, :config => Kurchatov::Config.to_hash, }.to_json + "\n" end end end end
Version data entries
13 entries across 13 versions & 1 rubygems