Spring Cloud based, distributed echo server.
- Java 11
- Docker
- Docker compose
- Gradle (4.0 or later)
- Build the project:
gradle clean build
- Or
./gradlew clean build
. In the case, required gradle version will be downloaded.
- Or
- Make
.env
file in root project directory - Put environment variable(with defined values) in the file:
CONFIG_SERVICE_PASSWORD
CONFIG_SERVICE_USER
DB_USER
DB_PASSWORD
DB_NAME
JWT_SIGNATURE_PRIVATE_KEY
JWT_SIGNATURE_PUBLIC_KEY
JWT_SIGNATURE_PRIVATE_KEY
and JWT_SIGNATURE_PUBLIC_KEY
is a valid pair of RS256 keys.
The keys can be generated with generateKeyPair.sh
script, placed in the project root.
All the services should have link to a Config service. The link should be passed as property:
-Dspring.cloud.config.uri=http://localhost:8888
Or the property(spring.cloud.config.uri
) can be passed via your IDE.
In Config service, there is shared configuration for 'dev' profile: application-dev.yml
The configuration points at local Discovery service instance http://localhost:8761/eureka/
To get the corresponding configuration, 'dev' profile should be activated for each service.
docker-compose -f docker-compose.yml -f docker-compose-dev.yml up
docker-compose.dev.yml
inherits docker-compose.yml
with additional possibility to build images locally
and expose all containers ports for convenient development.
docker-compose -f docker-compose.yml up
POST http://localhost:4000/auth/login
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,ru;q=0.8
Content-Type: application/json
{
"login": "test",
"password": "test"
}
###
Token will be generated as response. The token can be used in a next request.
GET http://localhost:4000/echos/echo/asdasd
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,ru;q=0.8
Content-Type: application/json
Authorization: Bearer -=token=-
###
The request made to Echo service, via Gateway(Zuul).