Skip to content

A reverse proxy server that records and replays HTTP responses

License

Notifications You must be signed in to change notification settings

hexdigest/gmeter

Repository files navigation

GMeter License Build Status Coverage Status Go Report Card GoDoc

A simple reverse proxy server that records HTTP requests and replays HTTP responses. GMeter can be used for testing programs that make HTTP requests to third-party services.

Installation

go get github.com/hexdigest/gmeter/cmd/gmeter

Alternatively you can download one of the pre-built executables:

Usage

  -d string
    	cassettes dir (default ".")
  -h	display this help text and exit
  -insecure
    	skip HTTPs checks
  -l string
    	listen address (default "localhost:8080")
  -t string
    	target base URL

Start gmeter:

$ gmeter -t http://github.com 
2018/03/05 00:06:19 started proxy localhost:8080 -> http://github.com

Put gmeter in recording mode:

$ curl -X POST http://localhost:8080/gmeter/record -d'{"cassette": "github_test"}'

Once you see something like:

2018/03/05 00:08:14 started recording of the cassette: github_test

Now you can start recording requests/responses. Lets request github index page:

$ curl http://localhost:8080/ -v
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Content-Length: 0
< Location: https://github.com/
< Date: Sun, 04 Mar 2018 21:11:25 GMT
< Content-Type: text/plain; charset=utf-8
< 
* Connection #0 to host localhost left intact

Both request and response now recorded and present in the github_test.cassette file that can be replayed. In order to replay a cassette you have to put gmeter in play mode by making following request:

$ curl -X POST http://localhost:8080/gmeter/play -d'{"cassette": "github_test"}'

Now you can request github index page again and get a recorded response from the cassette.

About

A reverse proxy server that records and replays HTTP responses

Resources

License

Stars

Watchers

Forks

Packages

No packages published