Skip to content

Commit 451e4e0

Browse files
committed
add a common proxy on mock server
1 parent b085a16 commit 451e4e0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pkg/mock/in_memory.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ func (s *inMemoryServer) Load() (err error) {
102102
}
103103

104104
s.handleOpenAPI()
105+
106+
for _, proxy := range server.Proxies {
107+
memLogger.Info("start to proxy", "target", proxy.Target)
108+
s.mux.HandleFunc(proxy.Path, func(w http.ResponseWriter, req *http.Request) {
109+
fmt.Println("catch all", req.URL.Path)
110+
})
111+
}
105112
return
106113
}
107114

pkg/mock/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ type Webhook struct {
5555
Request Request `yaml:"request" json:"request"`
5656
}
5757

58+
type Proxy struct {
59+
Path string `yaml:"path" json:"path"`
60+
Target string `yaml:"target" json:"target"`
61+
}
62+
5863
type Server struct {
5964
Objects []Object `yaml:"objects" json:"objects"`
6065
Items []Item `yaml:"items" json:"items"`
66+
Proxies []Proxy `yaml:"proxies" json:"proxies"`
6167
Webhooks []Webhook `yaml:"webhooks" json:"webhooks"`
6268
}

0 commit comments

Comments
 (0)