How to store and access html files from spring cloud config server?

735 views Asked by At

I wanted to externalise the email templates to send email notifications so I am storing them in a templates folder in GIT repository which is mapped to our spring-cloud-config server.

The templates folder in git repository has some .html files. Can someone help me with the cloud config URL to access .html files.

1

There are 1 answers

0
Jon Ruddell On

Generate App

For example, taking a default microservice app with a baseName of ms created with jh import-jdl --inline "application { config { applicationType microservice, baseName ms } }"

Add HTML File

Add a file src/main/docker/central-server-config/localhost-config/example.html:

<html><body><h1>${configserver.name}</h1></body></html>

Start the JHipster Registry

Start the JHipster Registry with docker-compose -f src/main/docker/jhipster-registry.yml up -d which will serve the config and HTML file we created.

Request the HTML File

To access this file through the JHipster Registry, you can use the following URL. Any variables in the templates will be replaced with the config variable present in the JHipster Registry config file. The format is: http://user:password@registry-url:8761/config/app-name/profile/git-label/example.html:

curl http://admin:admin@localhost:8761/config/ms/prod/master/example.html

Which will return:

<html><body><h1>Docker JHipster Registry</h1></body></html>