title: How to set up Grails 3 UrlMappings.groovy file so that there is no default url mapping?
body: <p>I have an issue that I'm facing while upgrading from Grails 2 to Grails 3. In my Grails 2 project, I had a UrlMappings.groovy file that looked like this:</p>
  
  <pre><code>class UrlMappings {
      static mappings = {
          //"/$controller/$action?/$id?(.$format)?"{
          //    parseRequest = false
          //    constraints {
                  // apply constraints here
          //    }
          //}
  
          "/$controller/$id" {
              action = [GET: "show", PUT: "update",
                        DELETE: "delete"]
  
              constraints {
                  // to constrain the id to numeric, uncomment the following:
                  //id matches: /\d+/
              }
          }
  
          "/$controller/$action" {
              constraints {
                  action matches: /external.*/
              }
          }
  
          "/$controller" {
              action = [GET: "list", POST: "create"]
              parseRequest = true
          }
  
          "/$controller/$action/$id" {
          }
  
          "/$controller/search" {
              action = [POST: "search"]
              parseRequest = true
          }
  
          "/$controller/count" {
              action = [GET: "count"]
          }
  
          "/"(view:"/index")
          "500"(controller: 'error')
      }
  }
  </code></pre>
  
  <p>This worked well as it would automatically hit a certain action when a certain format of URL was used (e.g. GET <a href="http://localhost:8090/api/test" rel="nofollow noreferrer">http://localhost:8090/api/test</a> would hit the TestController's list action).</p>
  
  <p>In my new Grails 3 project, I have moved the mappings to the correct location (grails-app/controllers/my.project.package), and the package is specified at the top of the file. I want the behavior to stay the same as specified in the example above. However, I see an internal server error when I hit the endpoint now.</p>
  
  <p>I believe I receive the internal server error because my TestController does not have an index action in it and the URL GET <a href="http://localhost:8090/api/test" rel="nofollow noreferrer">http://localhost:8090/api/test</a> is trying to hit an index action instead of the list action.</p>
  
  <p>I have generated the URL mappings report for both new and old projects, and I see that the Grails 3 project's URL mappings report contains the default URL mapping ( <code>|    *     | /${controller}/${action}?/${id}?(.${format)?              | Action: (default action)                                |</code>) even though it is commented out in the URL mapping. This is still generated after performing a clean and removing the commented out bit from the URLMappings.groovy file. Could this default mapping be the issue? If so, is there a way to stop the app from using it?</p>
  
  <p>One thing I have tried is using a constraint like <code>controller(validator: { return false })</code> in the constraints block of the mapping for <code>"/$controller/$action?/$id?(.$format)?"</code>. Another thing I have tried is using a different format for my custom URL mappings like</p>
  
  <pre><code>get "/$controller/$id"(action: "show")
  put "/$controller/$id"(action: "update")
  delete "/$controller/$id"(action: "delete")
  get "/$controller"(action: "list")
  post "/$controller"(action: "create")
  post "/$controller/search"(action: "search")
  get "/$controller/count"(action: "count")
  </code></pre>
  
  <p>Unfortunately, I did not have any luck with either of these solutions. I did have luck with using the static controller names (e.g. <code>"/test" { controller = "test", action = [GET: "list", POST: "create"] }</code>), but I would have to do this for many different controllers which isn't great for me.</p>
  
  <p>Please let me know if anyone has worked around or solved this issue. I would greatly appreciate it!</p>