A REST API for mocking other REST API responses.
- Run
./gradlew clean installDist
to build theapp.jar
required to build the docker image - Run
docker-compose build
to build the docker image containing the app - Run
docker-compose up
to start the service
Post a new mock with your expected response:
curl -X POST -d '{"method":"get","status":200,"headers":{"Content-Type":"application/json"},"body":"{\"message\":\"Hello, World!\"}"}' http://localhost/mock
You might escape your body as the example above.
You'll get a response like this:
{
"id":"73f01ced-48be-46ff-ad68-5f4103517d3b",
"method":"get",
"status":200,
"headers":{
"Content-Type":"application/json"
},
"body":"{\"message\":\"Hello, World!\"}"
}
Now you have your mock id, you can try it:
curl -v http://localhost/mock/73f01ced-48be-46ff-ad68-5f4103517d3b
You'll get the response mock you requested earlier:
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /mock/73f01ced-48be-46ff-ad68-5f4103517d3b HTTP/1.1
> Host: localhost
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 12 Feb 2018 20:27:35 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Server: Jetty(9.4.6.v20170531)
<
* Connection #0 to host localhost left intact
{"message":"Hello, World!"}