Grails
  1. Grails
  2. GRAILS-7941

If the allowed method is POST/GET introduce a variable to redirect to it some action

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • 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.

        Activity

        Raviteja created issue -
        Burt Beckwith made changes -
        Field Original Value New Value
        Workflow Grails2 [ 69879 ] jira [ 75919 ]
        Burt Beckwith made changes -
        Workflow jira [ 75919 ] Grails2 [ 84659 ]
        Peter Ledbrook made changes -
        Last Reviewed 01/Jan/10
        Peter Ledbrook made changes -
        Workflow Grails2 [ 84659 ] jira [ 93094 ]
        Peter Ledbrook made changes -
        Workflow jira [ 93094 ] Grails2 [ 101262 ]
        Jeff Scott Brown made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Jeff Scott Brown [ brownj ]
        Resolution Won't Fix [ 2 ]

          People

          • Assignee:
            Jeff Scott Brown
            Reporter:
            Raviteja
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development