Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tkc/go-json-server
golang simple & quickly JSON mock server
https://github.com/tkc/go-json-server
go go-mock-testing golang json json-api json-server mock mock-server webserver
Last synced: about 13 hours ago
JSON representation
golang simple & quickly JSON mock server
- Host: GitHub
- URL: https://github.com/tkc/go-json-server
- Owner: tkc
- License: mit
- Created: 2018-11-04T22:03:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-22T13:06:32.000Z (over 2 years ago)
- Last Synced: 2024-06-19T06:47:30.624Z (5 months ago)
- Topics: go, go-mock-testing, golang, json, json-api, json-server, mock, mock-server, webserver
- Language: Go
- Homepage:
- Size: 1.9 MB
- Stars: 28
- Watchers: 5
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Go](https://github.com/tkc/go-json-server/workflows/Go/badge.svg?branch=master)
```
___ _ ___
/ __|___ _ | |__ _ ___ _ _ / __| ___ _ ___ _____ _ _
| (_ / _ \ | || / _` / _ \ ' \ \__ \/ -_) '_\ V / -_) '_|
\___\___/ \__/\__,_\___/_||_| |___/\___|_| \_/\___|_|
```simple and quick golang JSON mock server.
simulate an http server and return the specified json according to a custom route.- static json api server
- static file server
- [ ] cache response and reload
- [ ] change api.json path
- [ ] url param
- [ ] server deamon
- [ ] jwt or session auth
- [ ] error response
- [ ] access log
- [ ] E2E test sample source in Github Actions## Install
```bash
$ go get -u github.com/tkc/go-json-server
```## Prepare api.json
```bash
- api.json // required
- response.json
```See example
https://github.com/tkc/go-json-server/tree/master/example## Serve Mock Server
```bash
$ go-json-server
```### Sample Json Setting
`api.json`
```javascript
{
"port": 3000,
"endpoints": [
{
"method": "GET",
"status": 200,
"path": "/",
"jsonPath": "./health-check.json"
},
{
"method": "GET",
"status": 200,
"path": "/users",
"jsonPath": "./users.json"
},
{
"method": "GET",
"status": 200,
"path": "/user/1",
"jsonPath": "./user.json"
},
{
"path": "/file",
"folder": "./static"
}
]
}
````health-check.json`
```javascript
{
"status": "ok",
"message": "go-json-server"
}
````users.json`
```javascript
[
{
"id":1,
"name": "name"
}
]
````user.json`
```javascript
{
"id": 1,
"name": "name",
"address": "address"
}
```
## LicenseMIT ✨