Class: Mongrel2::JSONRequest

Inherits:
Request
  • Object
show all
Extended by:
Loggability
Defined in:
lib/mongrel2/jsonrequest.rb

Overview

The Mongrel2 JSON Request class. Instances of this class represent a JSSocket request from a Mongrel2 server.

Instance Attribute Summary collapse

Attributes inherited from Request

#body, #conn_id, #headers, #path, #raw, #sender_id

Instance Method Summary collapse

Methods inherited from Request

#extended_reply?, #inspect, parse, register_request_type, #remote_ip, #response, response_class, #server_chroot, #socket_id, subclass_for_method, #upload_done?, #upload_headers_match?, #upload_started?, #uploaded_file, #valid_upload?

Constructor Details

#initialize(sender_id, conn_id, path, headers, body, raw = nil) ⇒ JSONRequest

Parse the body as JSON.



23
24
25
26
27
28
# File 'lib/mongrel2/jsonrequest.rb', line 23

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

Instance Attribute Details

#dataObject (readonly)

The parsed request data



36
37
38
# File 'lib/mongrel2/jsonrequest.rb', line 36

def data
  @data
end

Instance Method Details

#is_disconnect?Boolean

Returns true if the request is a special Mongrel2 ‘disconnect’ notification.

Returns:

  • (Boolean)


41
42
43
# File 'lib/mongrel2/jsonrequest.rb', line 41

def is_disconnect?
  return true if self.data['type'] == 'disconnect'
end