Open qortex opened 4 years ago
Quick workaround, simply rename the key by hand:
module BodyParser
# To abide by Rack::Lint, where without a dot in the key name it should be string (here, it can be
# a Hash instead, so Rack::Lint throws)
class KeyRenamer
FROM_KEY = 'parsed_body'
TO_KEY = 'parsed_body.document'
def initialize(app, _opts = {})
@app = app
end
def call(env)
new_env = env
if new_env.key?(FROM_KEY)
new_env[TO_KEY] = new_env[FROM_KEY]
new_env.delete(FROM_KEY)
end
@app.call(new_env)
end
end
end
Btw, formal spec is here, which states:
The server or the application can store their own data in the environment, too. The keys must contain at least one dot, and should be prefixed uniquely.
Thanks for raising this issue. I'll try to update asap. I'll bump the version to express the breaking change.
Rack::Lint
enforces SPEC:Thus, enabling
Rack::Lint
middleware generates an exception:The CGI keys (named without a period) must have String values.
suggests a fix would be to rename it tobody_parser.document
or something like that, to abide by the convention. Although of course it would be a breaking change.