Class: Mongrel2::JSONRequest
- 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
-
#data ⇒ Object
readonly
The parsed request data.
Attributes inherited from Request
#body, #conn_id, #headers, #path, #raw, #sender_id
Instance Method Summary collapse
-
#initialize(sender_id, conn_id, path, headers, body, raw = nil) ⇒ JSONRequest
constructor
Parse the body as JSON.
-
#is_disconnect? ⇒ Boolean
Returns
true
if the request is a special Mongrel2 ‘disconnect’ notification.
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
#data ⇒ Object (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.
41 42 43 |
# File 'lib/mongrel2/jsonrequest.rb', line 41 def is_disconnect? return true if self.data['type'] == 'disconnect' end |