Files

20 lines
532 B
Ruby
Raw Permalink Normal View History

2023-08-04 00:40:13 +03:00
# frozen_string_literal: true
class ApiPathConsiderJsonMiddleware
def initialize(app)
@app = app
end
def call(env)
if env['PATH_INFO'].starts_with?('/api') &&
2024-01-19 09:54:49 +02:00
(!env['PATH_INFO'].ends_with?('/documents') || env['REQUEST_METHOD'] != 'POST') &&
2025-04-08 15:24:17 +03:00
!env['PATH_INFO'].ends_with?('/attachments') &&
!env['PATH_INFO'].ends_with?('/submitter_sms_clicks') &&
!env['PATH_INFO'].ends_with?('/submitter_email_clicks')
2023-08-04 00:40:13 +03:00
env['CONTENT_TYPE'] = 'application/json'
end
@app.call(env)
end
end