require 'json'

module Ldash
  module RestHelpers
    def json!
      request.body.rewind
      JSON.parse(request.body.read)
    rescue
      # Invalid JSON
      halt 400, '{"message": ""}'
    end
  end
end
require 'json'

module Ldash
  module RestHelpers
    def fail_invalid(ldash_message, status = 400, discord_message = '')
      halt status, %Q({"message": "#{discord_message}", "l-": "#{ldash_message}"})
    end

    def json!
      request.body.rewind
      JSON.parse(request.body.read)
    rescue
      # Invalid JSON
      fail_invalid 'invalid JSON'
    end
  end
end
Make a fail_invalid helper that creates a Discord format response
Make a fail_invalid helper that creates a Discord format response
