The history of the investigation began with the business need to record every user action at a single point of change. (Something like Audit Logging of the User actions)
As a result of the investigation, it was found that it is possible to send both the request and the response received by Kong to the external system (some kind of ms-audit)
NOTE: In order to automatically start the network (included the kong and app) , you are able to use the start.sh shell script buy executing following command in the root:
./start.sh
In case of lack of permission use below command beforechmod a+rx start.sh
The detailed description of the commands can be found below.
cd ms-request-verify
gradle clean build
docker build --build-arg JAR_FILE=build/libs/\*.jar -t demo-app/ms-request-verify .
cd ..
docker compose up -d
docker cp request-response-logger/. kong:/usr/local/share/lua/5.1/kong/plugins/request-response-logger
docker restart kong
curl --location --write-out --request POST "http://localhost:8001/services" --header "Content-Type:application/json" --data-raw '{"name":"ms-request-verify","url" :"http://ms-request-verify:8080"}'
curl --location --write-out --request POST "http://localhost:8001/services/ms-request-verify/routes" \
--header "Content-Type:application/json" \
--data-raw '{
"name": "ms-request-verify-routes0",
"paths": [
"/"
],
"strip_path": true
}'
curl --location --write-out --request POST "http://localhost:8001/plugins" \
--header "Content-Type:application/json" \
--data-raw '{
"name":"request-response-logger",
"enabled":true
}'
5. Ping the new end point and see from the logs if the request and response is logged with command "docker logs ms-request-verify"
curl --location --request GET 'http://localhost:8000/api/v1/ping' \
--header 'x-request-id: 1111'
docker logs ms-request-verify