How to access config.groovy values in your controller?

404 views Asked by At

I have set login endpointUrl in config.groovy as

grails.plugin.springsecurity.rest.login.endpointUrl = "/api/login"

How to access this endpointUrl values in your controller ?

2

There are 2 answers

0
Cookalino On

In a controller you can use:

Holders.config.grails.plugin.springsecurity.rest.login.endpointUrl

Or:

grailsApplication.config.grails.plugin.springsecurity.rest.login.endpointUrl

See: This answer

0
Svetozar Misljencevic On

Personally, I'm not a big fan of Holders because it makes your code a bit harder to test. Instead, I prefer to inject config to avoid having a dependency on the Holders class: @Value('${grails.plugin.springsecurity.rest.login.endpointUrl}') def endpointUrl