Files
docuseal/lib/api_path_consider_json_middleware.rb
T
2024-01-19 09:54:49 +02:00

18 lines
402 B
Ruby

# frozen_string_literal: true
class ApiPathConsiderJsonMiddleware
def initialize(app)
@app = app
end
def call(env)
if env['PATH_INFO'].starts_with?('/api') &&
(!env['PATH_INFO'].ends_with?('/documents') || env['REQUEST_METHOD'] != 'POST') &&
!env['PATH_INFO'].ends_with?('/attachments')
env['CONTENT_TYPE'] = 'application/json'
end
@app.call(env)
end
end