A Simple HTTP server which will respond with what you tell it to through a JSON file.
It will respond with the first match in the config JSON file.
Project is forked from jasonrm/dummy-server.
$ docker run -it -p 8080:8080 nicoeg/dummy-http-server
Note: the custom config file needs to be mounted into the docker container for the HTTP server to use it.
$ docker run -v $PWD/config.json:/app/config.json -it -p 8080:8080 nicoeg/dummy-http-server
Usage of ./dummy-http-server:
-port int
port number (default 8080)
-config string
path to config file (default config.json)
Use the config to match different requests. Configuration is loaded on each request right now to allow for easy testing.
When match keys are not present they will be ignored.
Example configuration
[
{
"match": {
"url": "/data",
"method": "GET"
},
"response": {
"status": 200,
"body": "success"
}
},
{
"match": {
"url": "/match-any-method",
},
"response": {
"status": 403,
"body": "Forbidden"
}
},
{
"match": {
"url": "/:can-be-any-route-segment/other",
},
"response": {
"status": 200,
"body": "Cool"
}
},
{
"match": {
"url": "/test/last-can-be-optional?",
},
"response": {
"status": 200,
"body": "Sick"
}
}
]
- Point output of response to file
- Match on body, query, and headers
- Listen for config file changes instead of loading on each request