Stateful mock server
Start In The Middle
go run main/main.go -record
Set browser's proxy to In The Middle's listening IP and port and start the activities.
go run main/main.go
Replaying recorded activities, In-The-Middle will load activities from stub.json from export folder
.
-record
to start record mode. Default isfalse
.-ip <ip>
to specify listening IP address. Default is0.0.0.0
.-port <ip>
to specify listening port. Default is8080
.-export <path>
to specify exporting directory. Default is./fixtures
.-?
to show options screen.
Use go get ./...
to install all dependencies.
github.com/fatih/color
gopkg.in/elazarl/goproxy.v1
github.com/kr/pretty
gopkg.in/xmlpath.v1
github.com/jmoiron/jsonq
See examples
directory for example.
- Start in-the-middle in RECORD mode with default setting.
- Use
curl --proxy http://localhost:8080 http://anyHTTPdomain
to record request and response. You should see request and response in in-the-middle console log. - Stop in-the-middle by Ctrl-C. File stub.json should be created in ./fixtures folder.
- Start in-the-middle in REPLAY mode with default setting.
- Use
curl --proxy http://localhost:8080 http://anyHTTPdomain
to get cached response. If request hits cache, you should see "Cache HIT" message in in-the-middle console. Otherwise, you should see "Cache MISSED" message. - You can modify cached content by editing files in ./fixtures folder.