Skip to content

Commit efea03c

Browse files
authored
Merge branch 'master' into feat/request-log
2 parents f75042d + 9b844d0 commit efea03c

File tree

5 files changed

+59
-6
lines changed

5 files changed

+59
-6
lines changed

.github/workflows/go.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Go
2+
on: [push]
3+
jobs:
4+
5+
build:
6+
name: Build
7+
runs-on: ubuntu-latest
8+
steps:
9+
10+
- name: Set up Go 1.13
11+
uses: actions/setup-go@v1
12+
with:
13+
go-version: 1.13
14+
id: go
15+
16+
- name: Check out code into the Go module directory
17+
uses: actions/checkout@v2
18+
19+
- name: Get dependencies
20+
run: |
21+
go get -v -t -d ./...
22+
if [ -f Gopkg.toml ]; then
23+
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
24+
dep ensure
25+
fi
26+
- name: Build
27+
run: go build -v .

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# go-json-server
1+
2+
![Go](https://github.com/tkc/go-json-server/workflows/Go/badge.svg?branch=master)
3+
4+
```
5+
___ _ ___
6+
/ __|___ _ | |__ _ ___ _ _ / __| ___ _ ___ _____ _ _
7+
| (_ / _ \ | || / _` / _ \ ' \ \__ \/ -_) '_\ V / -_) '_|
8+
\___\___/ \__/\__,_\___/_||_| |___/\___|_| \_/\___|_|
9+
10+
```
211

312
simple and quick golang JSON mock server
413

@@ -19,7 +28,7 @@ simple and quick golang JSON mock server
1928
go install github.com/tkc/go-json-server
2029
```
2130

22-
## Serve
31+
## Serve Mock Server
2332
```bash
2433
go-json-server
2534
```
@@ -36,6 +45,12 @@ put api.json and run `go-json-server`
3645
{
3746
"port": 3000,
3847
"endpoints": [
48+
{
49+
"method": "GET",
50+
"status": 200,
51+
"path": "/",
52+
"jsonPath": "./health-check.json"
53+
},
3954
{
4055
"method": "GET",
4156
"status": 200,
@@ -56,12 +71,12 @@ put api.json and run `go-json-server`
5671
}
5772
```
5873

59-
`user.json`
74+
75+
`health-check.json`
6076
```javascript
6177
{
62-
"id": 1,
63-
"name": "name",
64-
"address": "address"
78+
"status": "ok",
79+
"message": "go-json-server started"
6580
}
6681
```
6782

example/api.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"port": 3000,
33
"endpoints": [
4+
{
5+
"method": "GET",
6+
"status": 200,
7+
"path": "/",
8+
"jsonPath": "./health-check.json"
9+
},
410
{
511
"method": "GET",
612
"status": 200,

example/health-check.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"status": "ok",
3+
"message": "go-json-server started"
4+
}

go-json-server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func main() {
125125
}
126126
}
127127

128+
128129
func response(w http.ResponseWriter, r *http.Request) {
129130

130131
r.ParseForm()

0 commit comments

Comments
 (0)