Sha256: 65b3c02f1d2874b84855b67c4f0ad688f0ed534de9a48afab730a85aa395e1e5
Contents?: true
Size: 904 Bytes
Versions: 1
Compression:
Stored size: 904 Bytes
Contents
# encoding: utf-8 require 'hatetepe' class HelloServer def serve(request, served) p request.http_method # => :get p request.uri # => "/" p request.headers # => {"Host"=>"127.0.0.1:3000", # "Content-Length"=>"0"} p request.body.to_s # => "" served.fulfill(response) end def response Hatetepe::Response.new(200, { 'Content-Type' => 'text/plain' }, 'hello') end end Hatetepe.run do Hatetepe::Server.start(address: '127.0.0.1', port: 3000, handlers: [HelloServer]) client = Hatetepe::Client.new(address: '127.0.0.1', port: 3000) response = client.request(:get, '/') p response.status # => 200 p response.status_name # => "OK" p response.headers # => {"Content-Type"=>"text/plain", # "Content-Length"=>"5"} p response.body.to_s # => "hello" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hatetepe-0.6.0.pre.2 | examples/getting_started.rb |