lib/hanami/middleware/body_parser.rb in hanami-router-2.0.0.rc1 vs lib/hanami/middleware/body_parser.rb in hanami-router-2.0.0
- old
+ new
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require "hanami/router/params"
require "hanami/middleware/error"
+require_relative "../router/constants"
module Hanami
module Middleware
# @since 1.3.0
# @api private
@@ -26,13 +27,10 @@
# @since 1.3.0
# @api private
ROUTER_PARAMS = "router.params"
# @api private
- ROUTER_PARSED_BODY = "router.parsed_body"
-
- # @api private
FALLBACK_KEY = "_"
extend ClassInterface
def initialize(app, parsers)
@@ -45,11 +43,11 @@
return @app.call(env) if body.empty?
env[RACK_INPUT].rewind # somebody might try to read this stream
if (parser = @parsers[media_type(env)])
- env[ROUTER_PARSED_BODY] = parser.parse(body)
- env[ROUTER_PARAMS] = _symbolize(env[ROUTER_PARSED_BODY])
+ env[Router::ROUTER_PARSED_BODY] = parser.parse(body)
+ env[ROUTER_PARAMS] = _symbolize(env[Router::ROUTER_PARSED_BODY])
end
@app.call(env)
end