DbConsole dynamic URLMappings.groovy

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

DbConsole dynamic URLMappings.groovy

Dencel
Hello,

I have the following URLmappings.groovy:
static mappings = {
        "/$blog/$action?"(controller:blogger)
}

But if I want to access the dbconsole using /dbconsole it always goes to the blog controller.

Is there a way to configure /dbconsole takes precedence over /$blog/$action?

Greetings Dennie
Reply | Threaded
Open this post in threaded view
|

Re: DbConsole dynamic URLMappings.groovy

Ian Roberts
On 27/09/2012 13:47, Dennie.nl wrote:

> Hello,
>
> I have the following URLmappings.groovy:
> static mappings = {
>         "/$blog/$action?"(controller:blogger)
> }
>
> But if I want to access the dbconsole using /dbconsole it always goes to
> the blog controller.
>
> Is there a way to configure /dbconsole takes precedence over
> /$blog/$action?

When more than one URL mapping can match the same incoming request URI
there's a set of precedence rules that decide which one wins:

http://grails.1312388.n4.nabble.com/URL-Mapping-question-tp3556768p3565451.html

In short, "/$blog/$action?" is considered more specific than
"/$controller/$action?/$id?" because it contains fewer wildcards.  You
can work around it by either adding a specific mapping for dbconsole

"/dbconsole"(controller:"dbconsole")

or by putting a constraint on the "$blog/$action?" mapping to prevent it
from matching a blog called dbconsole

"/$blog/$action?"(controller:'blogger') {
  constraints {
    blog(notEqual:'dbconsole')
  }
}

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: DbConsole dynamic URLMappings.groovy

Ian Roberts
On 27/09/2012 14:17, Ian Roberts wrote:
> "/dbconsole"(controller:"dbconsole")

Actually, ignore me, it doesn't look like the dbconsole is implemented
by a controller, it's done by a special <servlet-mapping> inserted into
web.xml when the console has been enabled in Config.groovy.  You have
enabled it in Config.groovy, right?

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: DbConsole dynamic URLMappings.groovy

Dencel
Yeah, that is exactly what I was thinking. I've tried excluding the /dbconsole url using static excludes=['/dbconsole'] but this simply makes Grails ignore the mapping altogether.
I don't think there is a good solution for this problem.

2012/9/27 Ian Roberts <[hidden email]>
On 27/09/2012 14:17, Ian Roberts wrote:
> "/dbconsole"(controller:"dbconsole")

Actually, ignore me, it doesn't look like the dbconsole is implemented
by a controller, it's done by a special <servlet-mapping> inserted into
web.xml when the console has been enabled in Config.groovy.  You have
enabled it in Config.groovy, right?

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: DbConsole dynamic URLMappings.groovy

tommytcchan
The answer lies in the use of the `constraints` param:

Having something like this will work:

                "/${screenName}" {
                        controller = 'profile'
                        action = 'profile'
                        constraints { screenName(notEqual: 'dbconsole') }}
Reply | Threaded
Open this post in threaded view
|

Re: DbConsole dynamic URLMappings.groovy

tommytcchan
In reply to this post by Dencel