Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Ananto30/gmocker
Create a blazing fast mock server with just a JSON file
https://github.com/Ananto30/gmocker
fasthttp go golang mock-server
Last synced: 12 days ago
JSON representation
Create a blazing fast mock server with just a JSON file
- Host: GitHub
- URL: https://github.com/Ananto30/gmocker
- Owner: Ananto30
- License: mit
- Created: 2021-05-18T08:17:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-24T06:15:32.000Z (5 months ago)
- Last Synced: 2024-08-02T05:12:22.700Z (3 months ago)
- Topics: fasthttp, go, golang, mock-server
- Language: Go
- Homepage:
- Size: 14.1 MB
- Stars: 54
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-blazingly-fast - gmocker - Create a blazing fast mock server with just a JSON file (Go)
README
# Gmocker
[![codecov](https://codecov.io/gh/Ananto30/gmocker/branch/main/graph/badge.svg?token=ulDcbeJyak)](https://codecov.io/gh/Ananto30/gmocker)
[![Maintainability](https://api.codeclimate.com/v1/badges/8d035908151fad8489ee/maintainability)](https://codeclimate.com/github/Ananto30/mocker/maintainability)
[![Go Report Card](https://goreportcard.com/badge/github.com/Ananto30/mocker)](https://goreportcard.com/report/github.com/Ananto30/mocker)Run a blazing fast mock server in just seconds! 🚀
All you need is to make a json file that contains path and response mapping. See an example [here](https://github.com/Ananto30/mocker#sample-mockjson-file).
*Only json is supported for now, please create issues for bugs and new features.*
## Run
With defaults -
```bash
./mocker
```
**Defaults: `addr=localhost:7070` , `file=mock.json`**With custom flags -
```bash
./mocker -addr -file
```For windows -
```powershell
mocker.exe -addr -file
```## Sample mock.json file
```
{
"": {
"statusCode": ,
"responseBody": {
...
}
}
}
```
These `path`s will be matched and the json will be sent.Example -
```json
{
"/hello/worlds": {
"statusCode": 200,
"responseBody": {
"message": "Hello worlds!",
"data" : {
"time": "now"
},
"worlds": [
"cross origin world",
"mars world",
"moon world"
]
}
}
}
```
If a request lands in the server in path `/hello/worlds` the json object inside `responseBody` will be sent as response.**The request type [POST or GET] doesn't matter.**
## Build
For mac/linux -
```bash
go mod download
go build
```For windows -
```bash
go mod download
GOOS=windows GOARCH=amd64 go build
```**If the build/binary doesn't work for you, you can do this -
- Check your os and arch using this command - `go env GOOS GOARCH`
- Use the output os and arch to build the binary - `GOOS= GOARCH= go build`