Rack::Multipart.parse_multipart env
config.ru
module Middleware
class MultipartParser
def initialize(app)
@app = app
end
def call(env)
if env["CONTENT_TYPE"] =~ /multipart\/form-data/
params = Rack::Multipart.parse_multipart(env).to_h
env["multipart_params"] = params
end
@app.call(env)
end
end
end
use Middleware::MultipartParser
run -> env { [200, {}, [env["multipart_params"].to_s] ] }