Skip to content

Commit 742cb98

Browse files
committed
Added dynamic routes for config.json
1 parent b9b44c7 commit 742cb98

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ To generate fake API responses, you must create a configuration file in JSON for
4848
}
4949
},
5050
{
51-
"url": "/products/id",
51+
"url": "/products/{id}",
5252
"fields": {
5353
"id": "uuid",
5454
"tags": [{

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ module github.com/paqstd-team/fake-cli
33
go 1.19
44

55
require github.com/brianvoe/gofakeit/v6 v6.20.1
6+
7+
require github.com/gorilla/mux v1.8.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
github.com/brianvoe/gofakeit/v6 v6.20.1 h1:8ihJ60OvPnPJ2W6wZR7M+TTeaZ9bml0z6oy4gvyJ/ek=
22
github.com/brianvoe/gofakeit/v6 v6.20.1/go.mod h1:Ow6qC71xtwm79anlwKRlWZW6zVq9D2XHE4QSSMP/rU8=
3+
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
4+
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=

handler/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"fmt"
66
"net/http"
77

8+
"github.com/gorilla/mux"
89
"github.com/paqstd-team/fake-cli/cache"
910
"github.com/paqstd-team/fake-cli/config"
1011
)
1112

1213
func MakeHandler(config config.Config) http.Handler {
13-
mux := http.NewServeMux()
14+
mux := mux.NewRouter()
1415
cache := cache.NewCache(config.Cache)
1516

1617
for _, endpoint := range config.Endpoints {

0 commit comments

Comments
 (0)