Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// in bootstrap.yml is defined spring.cloud.config.server.prefix = /config and client microservice call to
// org.springframework.cloud.config.server.resource.ResourceController. So in UrlMappings we need write our
// mapping for call - get "/config/${serviceName}/${profile}"(controller: 'configuration', action: 'config')
def config(String serviceName, String profile) {
def propertySources = [:]
propertySources.name = "${serviceName}.properties"
propertySources.source = [:]
// read from db all configurations for requested service
["application", "application-${profile}", "${serviceName}-${profile}"].each { configName ->
Configuration configuration = Configuration.findByName(configName)
if (configuration) {
configuration.configLines?.each { line ->
if (line) {
propertySources.source.put(line.label, line.value)
}
}
}
}
def environment = [name : "${serviceName}", profiles: ["${profile}"], "label": null, "version": null, "state": null,
propertySources: [propertySources]]
render(text: environment as JSON, contentType: "application/json")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment