module Roda::RodaPlugins::InvalidRequestBody
def self.configure(app, action=nil, &block)
Set the action to use (:empty_400, :empty_hash, :raise) for invalid request bodies,
def self.configure(app, action=nil, &block) if action if block raise RodaError, "cannot provide both block and action when loading invalid_request_body plugin" end method = :"handle_invalid_request_body_#{action}" unless RequestMethods.private_method_defined?(method) raise RodaError, "invalid invalid_request_body action provided: #{action}" end app::RodaRequest.send(:alias_method, :handle_invalid_request_body, method) elsif block app::RodaRequest.class_eval do define_method(:handle_invalid_request_body, &block) alias handle_invalid_request_body handle_invalid_request_body end else raise RodaError, "must provide block or action when loading invalid_request_body plugin" end app::RodaRequest.send(:private, :handle_invalid_request_body) end