Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.0-M1
-
Fix Version/s: None
-
Component/s: Controllers
-
Labels:None
Description
Instead of showing a 405 allow something like:
static allowedMethods = [[save: "POST",invalidMethodAction="create"], ... ]
which will redirect to some other action which can serve it's purpose which would be equivalent to: (ref: http://www.grails.org/doc/1.3.7/ref/Controllers/allowedMethods.html)
class PersonController {
def delete = {
if(request.method == 'GET') {
// redirect to the list action
redirect(action:list)
} else {
// the rest of the delete action goes here
}
}
}
Some gotcha's:
- As given in the above example save and create shouldn't be having the same allowed methods
- Case 1: save has "POST" and create has "POST". save pushes the get request to create and create shows a 405
- Case 2: save has suppose invalidMethodAction = create and create has invalidMethodAction = save. You'll experience a stackoverflow.