Sha256: 49c4d8d5914bede12aa7d1b388701dd6919814dfaac319f007dee0c0597b3936

Contents?: true

Size: 1.03 KB

Versions: 20

Compression:

Stored size: 1.03 KB

Contents

#!/usr/bin/ruby

require 'yajl'
require 'loggability'

require 'mongrel2/request' unless defined?( Mongrel2::Request )


# The Mongrel2 JSON Request class. Instances of this class represent a JSSocket request from
# a Mongrel2 server.
class Mongrel2::JSONRequest < Mongrel2::Request
	extend Loggability

	# Loggability API -- set up logging under the 'mongrel2' log host
	log_to :mongrel2

	# Mongrel2::Request API -- register this request type as handling 'JSON' requests
	register_request_type( self, :JSON )


	### Parse the body as JSON.
	def initialize( sender_id, conn_id, path, headers, body, raw=nil )
		super
		self.log.debug "Parsing JSON request body"
		@data = Yajl.load( body )
		self.log.debug "  body is: %p" % [ @data ]
	end


	######
	public
	######

	# The parsed request data
	attr_reader :data


	### Returns +true+ if the request is a special Mongrel2 'disconnect' 
	### notification.
	def is_disconnect?
		return true if self.data['type'] == 'disconnect'
	end

end # class Mongrel2::JSONRequest

# vim: set nosta noet ts=4 sw=4:

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
mongrel2-0.36.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.35.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.34.1.pre.357 lib/mongrel2/jsonrequest.rb
mongrel2-0.34.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.33.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.32.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.31.1 lib/mongrel2/jsonrequest.rb
mongrel2-0.31.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.30.1 lib/mongrel2/jsonrequest.rb
mongrel2-0.30.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.29.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.28.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.27.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.26.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.25.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.25.0.pre.288 lib/mongrel2/jsonrequest.rb
mongrel2-0.25.0.pre.285 lib/mongrel2/jsonrequest.rb
mongrel2-0.24.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.23.0 lib/mongrel2/jsonrequest.rb
mongrel2-0.22.1 lib/mongrel2/jsonrequest.rb