Repository navigation
Support mapping every controller as a REST resource - #16273
Merged
codeconsole merged 5 commits intoSep 2, 2026
Merged
Conversation
An application whose controllers all follow the RESTful resource conventions had to declare a resources mapping per controller, or hand-write the eight equivalent method-prefixed mappings. The first grows the mapping table with the controller count; the second copies a framework convention into application code, where it drifts when the convention changes. Passing '*' as the resources argument now generates the eight mappings once and leaves the controller to be resolved from the URL's own capture when a request is matched, which the existing runtime constraint evaluator already supports. includes, excludes and group prefixes compose as they do for a named resource. Because the controller is not known until a request is matched, two cases are rejected when the mappings are evaluated rather than left to produce mappings that cannot match: a URL that does not capture the controller, and a nested child resource, which would otherwise build a constraint named "nullId".
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #16273 +/- ##
==================================================
+ Coverage 54.7365% 54.7536% +0.0171%
- Complexity 20470 20473 +3
==================================================
Files 2103 2103
Lines 101077 101091 +14
Branches 17928 17934 +6
==================================================
+ Hits 55326 55351 +25
+ Misses 37876 37861 -15
- Partials 7875 7879 +4
🚀 New features to boost your workflow:
|
"/$namespace/$controller"(resources: '*') already worked, since the namespace token registers its own constraint and RegexUrlMapping has a runtime evaluator for it, but nothing pinned that down. The constraint ordering is what makes it work and is easy to break: namespace, then controller, then the id and format the resource mappings append, which have to line up with the regex group positions. Adds a spec asserting all four bind correctly, that literal segments still beat the id, and that a second namespace reuses the same eight mappings. Documents the form in the guide.
… into feat/wildcard-resources-mapping
codeconsole
requested review from
borinquenkid,
jamesfredley,
jdaugherty,
matrei and
sbglasius
September 2, 2026 03:43
✅ All tests passed ✅Test SummaryCI / Build Grails-Core (Windows JDK 25 shard 2) > :grails-async-core:test
🏷️ Commit: c427432 Test FailuresFutureTaskPromiseFactorySpec > Test promise onError handling (:grails-async-core:test in CI / Build Grails-Core (Windows JDK 25 shard 2) | Attempt 1/2)Learn more about TestLens at testlens.app/docs. |
jdaugherty
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An application whose controllers all follow the RESTful resource conventions has to declare a
resourcesmapping per controller, or hand-write the eight equivalent method-prefixed mappings. The first grows the mapping table with the controller count; the second copies a framework convention into application code, where it drifts when the convention changes.Passing
*as theresourcesargument applies the conventions to every controller:That generates the eight mappings once — not once per controller — and resolves the controller from the URL when a request is matched:
includes,excludesandgroupprefixes compose as they do for a named resource:The captured controller and action are validated as they are for any other wildcard mapping, so a URI that does not correspond to a registered controller and action does not match.
Limitations, both rejected when the mappings are evaluated rather than left to produce mappings that cannot match:
"/books"(resources: '*')is an error