Kee*_*eth 2 configuration grails
使用Grails OAuth插件需要在Config.groovy中提供绝对回调URL.但是,每个环境都有不同的serverURL.
有没有办法从Config.groovy内部获取当前环境,这是我想要做的一个例子:
def devServerUrl = 'http://dev.example.com'
def prodServerUrl = 'http://prod.example.com'
def currentServerUrl = grailsApplication.metadata.environment == 'development' ? devServerUrl : prodServerUrl;
environments {
development {
grails {
serverURL = devServerUrl
}
}
production {
grails {
serverURL = prodServerUrl
}
}
}
oauth {
providers {
runkeeper {
api = RunKeeperApi
key = 'key'
secret = 'secret'
callback = currentServerUrl + '/oauth/runkeeper/callback'
}
}
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢!
试试这个:
def currentServerUrl = Environment.current.name == 'development' ? devServerUrl : prodServerUrl;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4022 次 |
最近记录: |