Created
May 15, 2017 10:36
-
-
Save Tatsiana888/899e4889a1d4ba43b10ab5a4e327d282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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