Is there a way to do what theConfig.groovy
file does, but during the code execution...
Something like:
class AController{ def method(){ withEnvironments{ development{ println 'This is execute just on development' } production { log.debug 'This is execute just on production' } } } }
I know that I can achieve the same effect using if (Environment.current == 'development')
, but is there something with that sintax???
Found this blog post which shows one possible solution using Environment.executeForCurrentEnvironment
:
import grails.util.Environment
class AController {
def method() {
Environment.executeForCurrentEnvironment {
development {
println 'This is execute just on development'
}
production {
log.debug 'This is execute just on production'
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With