Sha256: 986a661949e040e4d52c26c6e0e7ee8c808da4aafec7575592a33f5c3a12dac6
Contents?: true
Size: 920 Bytes
Versions: 5
Compression:
Stored size: 920 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
5 entries across 5 versions & 1 rubygems