From 10be5dba8f46a8df48b614c144ba04fb99bde800 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 12 Sep 2023 10:34:06 -0700 Subject: [PATCH] Bump version to 3.72.0 --- CHANGELOG | 2 +- doc/release_notes/3.72.0.txt | 48 ++++++++++++++++++++++++++++++++++++ lib/roda/version.rb | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 doc/release_notes/3.72.0.txt diff --git a/CHANGELOG b/CHANGELOG index 3c07088d..8e4f7d00 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -= master += 3.72.0 (2023-09-12) * Add invalid_request_body plugin for custom handling of invalid request bodies (jeremyevans) diff --git a/doc/release_notes/3.72.0.txt b/doc/release_notes/3.72.0.txt new file mode 100644 index 00000000..3a3676fe --- /dev/null +++ b/doc/release_notes/3.72.0.txt @@ -0,0 +1,48 @@ += New Features + +* An invalid_request_body plugin has been added for allowing custom + handling of invalid request bodies. Roda uses Rack's request body + parsing, and by default invalid request bodies can result in + different exceptions based on how the body is invalid and which + version of Rack is in use. + + If you want to treat an invalid request body as the submission of + no parameters, you can use the :empty_hash argument when loading + the plugin: + + plugin :invalid_request_body, :empty_hash + + If you want to return a empty 400 (Bad Request) response if an + invalid request body is submitted, you can use the :empty_400 + argument when loading the plugin: + + plugin :invalid_request_body, :empty_400 + + If you want to raise a Roda::RodaPlugins::InvalidRequestBody::Error + exception if an invalid request body is submitted (which makes it + easier to handle these exceptions when using the error_handler + plugin), you can use the :raise argument when loading the plugin: + + plugin :invalid_request_body, :raise + + For custom behavior, you can pass a block when loading the plugin + The block is called with the exception Rack raised when parsing the + body. The block will be used to define a method in the application's + RodaRequest class. It can either return a hash of parameters, or + you can raise a different exception, or you can halt processing and + return a response: + + plugin :invalid_request_body do |exception| + # To treat the exception raised as a submitted parameter + {body_error: exception} + end + += Other Improvements + +* When using the check_arity: :warn Roda option, Roda now correctly + warns when defining a method that expects a single argument when + the provided block requires multiple arguments. + +* The match_hooks plugin is now implemented using the match_hook_args + plugin, simplifying the implementation. This change should be + transparent unless you were reaching into the internals. diff --git a/lib/roda/version.rb b/lib/roda/version.rb index 3148353c..9e708fd5 100644 --- a/lib/roda/version.rb +++ b/lib/roda/version.rb @@ -4,7 +4,7 @@ class Roda RodaMajorVersion = 3 # The minor version of Roda, updated for new feature releases of Roda. - RodaMinorVersion = 71 + RodaMinorVersion = 72 # The patch version of Roda, updated only for bug fixes from the last # feature release.