title: Grails custom URL mapping for user nicknames
body: <p>I have a custom URL name requirement.</p>
  
  <p>Each user will have a custom page and it must be at the root of the domain</p>
  
  <p>For example: http:www.bemdireto.com.br/eduardo</p>
  
  <p>This will conflict with default controller's mapping.</p>
  
  <p>The application already exists, so I cannot change the controllers url.</p>
  
  <p>We have came up with the following code</p>
  
  <pre><code> "/$controller/$action?/$id?"{
       controller = {
      def log = Logger.getLogger('br.com.fisgo.UrlMappings')
  
      log.trace "Verifying if a broker hot site or controller"
  
      def uri = delegate.getCurrentRequest().getRequestURI()
      log.info "Acessando uri: ${uri}"
  
      UrlMappingUtil.handleBrokerHotSiteController(uri, {owner -&gt;
         params.owner = owner
         })
      }
  
          action = {
              def uri = delegate.getCurrentRequest().getRequestURI()
              UrlMappingUtil.handleBrokerHotSiteAction(uri)
          }
      }
  </code></pre>
  
  <p>The method UrlMappingUtil.handleBrokerHotSiteController will tell controller and nickname apart.</p>
  
  <p>The problem is: the method is being executed 7 times for each request.</p>
  
  <p>I can't find the reason why.</p>
  
  <p>I've noticed that the urlMapping is called 3 times before de UrlMappingsFilter and 4 after.</p>