endpoints
endpoints copied to clipboard
The tiniest http endpoints simulator
The tiniest HTTP endpoints simulator
Endpoints
Usage
Download your binary here
On terminal
$ endpoints
Or, if you are into containers
On terminal
$ docker run ghcr.io/alexrios/endpoints:latest
You should see
INFO[0000] [GET] / -> 200 with body -> customBody.json
INFO[0000] Listen at :8080
Defaults
- address - ":8080"
- method - "GET"
- latency - 0ms
- status code - 200
Configuration file
endpoints.json
All features example:
{
"address": ":8080",
"responses": [
{
"path": "/",
"status": 201,
"latency": "400ms",
"method": "POST",
"json_body": "customBody.json"
}
]
}
Note: json_body is the file location of the body file.
Body interpolation with path variables
Now you want to interpolate an identifier on the response body. How to do it?
Let's add another response on responses.
{
"address": ":8080",
"responses": [
{
"path": "/",
"status": 200,
"latency": "400ms",
"method": "POST",
"json_body": "customBody.json"
},
{
"path": "/{id}/sales",
"status": 201,
"latency": "400ms",
"method": "GET",
"json_body": "interpolated.json"
}
]
}
And now, we'll use templating notation to use this response body as a template.
interpolated.json
{
"id": {{ .id}}
}
Status
This project is under development.