Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexrios/endpoints
The tiniest http endpoints simulator
https://github.com/alexrios/endpoints
emulator endpoint hacktoberfest mocking-server simulator
Last synced: about 1 month ago
JSON representation
The tiniest http endpoints simulator
- Host: GitHub
- URL: https://github.com/alexrios/endpoints
- Owner: alexrios
- Created: 2020-05-05T00:23:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-23T22:44:28.000Z (8 months ago)
- Last Synced: 2024-08-03T14:09:51.350Z (5 months ago)
- Topics: emulator, endpoint, hacktoberfest, mocking-server, simulator
- Language: Go
- Homepage:
- Size: 39.1 KB
- Stars: 30
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
The tiniest HTTP endpoints simulator
[![Go Report Card](https://goreportcard.com/badge/github.com/alexrios/endpoints)](https://goreportcard.com/report/github.com/alexrios/endpoints)
[![Download shield](https://img.shields.io/github/downloads/alexrios/endpoints/total)](https://img.shields.io/github/downloads/alexrios/endpoints/total)# Endpoints
### Usage
Download your binary [here](https://github.com/alexrios/endpoints/releases/latest)On terminal
```shell script
$ endpoints
```Or, if you are into containers
On terminal
```shell script
$ 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.jsonAll features example:
```json
{
"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`.
```json
{
"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.