Spring Cloud Server - Placeholder

I developed a microservice using Spring Boot. This service retrieves properties using the Spring Cloud Configuration Server. This microservice accepts the version in the header and, based on the version, performs the corresponding function. In my github registry, I have 2 branches, 1 for each version. A service typically sends the following information to a configuration server to get properties -

appname + profile + shortcut

Is there a way to have a placeholder instead of a label in my .yml file? I want the label to be set dynamically in v1 if I see v1 in the else v2 header.

EDIT:

I see links to placeholders in this documentation ( http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html ) under "Placeholders in a Git URI", however I'm not sure how the values ​​can dynamically substituted from an incoming request

+4
source share
1 answer

spring -cloud-config-server makes several REST APIs available, allowing you to directly request the properties file:

$ hostname:port/{label}/{name}-{profiles}.properties]

You can dynamically use any label of your choice if it matches an existing label on git.

For example, for extraction application.propertiestagged v1in git:

 $ http://${hostname}:${port}/v1/application.properties

Config Server REST API:

  • /{name}/{profiles}/{label:. *
  • /{}/{} - {} .properties
  • /{} - {} .json
  • /{}/{} - {} .json
  • /{}/{} - {} .yml
  • /{}/{} - {} .yaml
  • /{} - {} .yml
  • /{} - {} .yaml
  • /{}/{:.. [^ -]}
  • /{} - {} .properties
  • /{}/{}/{}/**

spring-cloud-server git. git v1 v2 ( remote):

label v1:

http://localhost:8888/v1/application-remote.properties
> testproperty: remotevalue-v1

label v2:

http://localhost:8888/v2/application-remote.properties
> testproperty: remotevalue-v2

:

http://localhost:8888/application-remote.properties
> testproperty: remotevalue-master

Java-

, , java- cloud-config-server ( , http-):

@Autowired
EnvironmentController environmentController;
...

Environment labelled = environmentController.labelled("application", "remote", "v1");
Map<?, ?> keyValues = labelled.getPropertySources().get(0).getSource();
0

All Articles