5

hi i want to obtain the grails url mappings from memory and change them dynamically. My doubt is where to get the url mappings from memory programatically ? is it available in the grailsapplication?

mahati
  • 209
  • 5
  • 10

1 Answers1

10

There's a UrlMappingsHolder Spring bean under the grailsUrlMappingsHolder name, so you can access the array of UrlMapping with:

def grailsUrlMappingsHolder
...
UrlMapping[] urlMappings = grailsUrlMappingsHolder.urlMappings
Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
  • For groovy files that do not have automated dependency injection, like security providers using the Spring security plugin, there also needs to be a couple lines in the `resources.groovy` file to inject this dependency. For instance, a rough example: `myAuthenticationProvider("MyAuthenticationProvider") { grailsUrlMappingsHolder=ref("grailsUrlMappingsHolder") }` – Jason Aug 27 '21 at 16:19