diff --git a/CHANGELOG b/CHANGELOG index 6168aa17..23d910f4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -= master += 3.87.0 (2024-12-17) * Add host_routing plugin for routing based on request host header (jeremyevans) diff --git a/doc/release_notes/3.87.0.txt b/doc/release_notes/3.87.0.txt new file mode 100644 index 00000000..d29edd8f --- /dev/null +++ b/doc/release_notes/3.87.0.txt @@ -0,0 +1,52 @@ += New Features + +* A host_routing plugin has been added, for easier routing based on + the request host. Example: + + plugin :host_routing do |hosts| + hosts.to :api, "api.example.com", "api2.example.com" + hosts.default :www + end + + route do |r| + r.api do + # requests to api.example.com or api2.example.com + end + + r.www do + # requests to other domains + end + end + + The plugin also adds request predicate methods: + + route do |r| + r.api? # true if the request is to api.example.com or api2.example.com + r.www? # true for request for other domains + end + + If the :scope_predicates plugin option is given, these predicate + methods are also supported directly in block scope (no "r."). + + For more advanced cases, such as prefix matches on the host, the + hosts.default method accepts a block. In this case, you should + also call hosts.register to notify the plugin about what hosts + the block could return: + + plugin :host_routing do |hosts| + hosts.register :api + hosts.default :www do |host| + :api if host.end_with?(".api.example.com") + end + end + += Other Improvements + +* In the custom_block_results plugin, if the block passed to + handle_block_result returns an object that is not a String, + nil, or false, Roda no longer attempts to write it to the response + body. Doing so is undesirable and would be a violation of the rack + spec. + +* Minor performance improvements have been made to the header_matchers + plugin. diff --git a/lib/roda/version.rb b/lib/roda/version.rb index 386947a2..7edd2741 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 = 86 + RodaMinorVersion = 87 # The patch version of Roda, updated only for bug fixes from the last # feature release.