mmock for mocking microservices
It is a very easy to set up though pretty powerful tool with support for delays and handling query params.
It also has a console for checking all the requests and corresponding responses matched.
Here it is https://github.com/jmartin82/mmock.
Below I describe a way to use it with docker-compose for local development.
./assets/mock_servers/service1/validation.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
request: description: "Handlingvalidation" method: GET path: "/api/v5/groupie/validate_participant/*" response: statusCode: 200 headers: Content-Type: - "application/json" body: > { "data": { "groupie_id": "", "host": { "name": "John Doe", "code": "w3er" } } } |
./docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 |
... service1: container_name: service1 hostname: service1 image: jordimartin/mmock ports: - "8011:8083" # server port - "9011:8082" # console port volumes: - ./assets/mock_servers/service1:/config networks: - my-network ... |
Then inside other containers you can request it as
curl -X GET "http://service1:8083/api/v5/groupie/validate_participant/111"
.
From your host machine you can request it as
curl -X GET "http://localhost:8011/api/v5/groupie/validate_participant/111"
.
And if you open http://localhost:9011/, you will see this request being matched by the config your provided.
Similar Posts
LEAVE A COMMENT
Для отправки комментария вам необходимо авторизоваться.