Sha256: eb0990bc37f5b6b8672853e1fbe60fba373a99e61853dad9e91703f978aa9ec3

Contents?: true

Size: 708 Bytes

Versions: 12

Compression:

Stored size: 708 Bytes

Contents

module Plezi
	#####
	# this is a Handler stub class for an HTTP echo server.
	module HTTPEcho
		module_function

		# handles requests by printing out the parsed data. gets the `request` parameter from the HTTP protocol.
		def on_request request
			response = HTTPResponse.new request, 200, {'content-type' => 'text/plain'}, ["parsed as:\r\n", request.to_s]
			response.body.last << "\n\n params:"
			request.params.each {|k,v| response.body.last << "\n#{k}: #{v}"}
			response.send
			response.finish
		end

		# does nothing - a simple stub as required from handlers
		def add_route *args
			self
		end

		# does nothing - a simple stub as required from handlers
		def add_host *args
			self
		end
	end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
plezi-0.9.2 lib/plezi/handlers/http_echo.rb
plezi-0.9.1 lib/plezi/handlers/http_echo.rb
plezi-0.9.0 lib/plezi/handlers/http_echo.rb
plezi-0.8.7 lib/plezi/handlers/http_echo.rb
plezi-0.8.6 lib/plezi/handlers/http_echo.rb
plezi-0.8.5 lib/plezi/handlers/http_echo.rb
plezi-0.8.4 lib/plezi/handlers/http_echo.rb
plezi-0.8.3 lib/plezi/handlers/http_echo.rb
plezi-0.8.2 lib/plezi/handlers/http_echo.rb
plezi-0.8.1 lib/plezi/handlers/http_echo.rb
plezi-0.7.7 lib/plezi/handlers/http_echo.rb
plezi-0.7.6 lib/plezi/handlers/http_echo.rb