Module: JSONAPI::Parser
- Defined in:
- lib/easy/jsonapi/parser.rb,
lib/easy/jsonapi/parser/json_parser.rb,
lib/easy/jsonapi/parser/headers_parser.rb,
lib/easy/jsonapi/parser/document_parser.rb,
lib/easy/jsonapi/parser/rack_req_params_parser.rb
Overview
Parsing logic in rack middleware
Defined Under Namespace
Modules: DocumentParser, HeadersParser, JSONParser, RackReqParamsParser
Class Method Summary collapse
-
.parse_request(env) ⇒ JSONAPI::Request
The instantiated jsonapi request object.
Class Method Details
.parse_request(env) ⇒ JSONAPI::Request
Returns the instantiated jsonapi request object.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/easy/jsonapi/parser.rb', line 15 def self.parse_request(env) req = Rack::Request.new(env) query_param_collection = RackReqParamsParser.parse(req.GET) header_collection = HeadersParser.parse(env) req_body = req.body.read # stored separately because can only read 1x req.body.rewind # rewind incase something else needs to read the body of the request document = includes_jsonapi_document?(env) ? DocumentParser.parse(req_body) : nil JSONAPI::Request.new(env, query_param_collection, header_collection, document) end |