2017-11-08 00:10:54 +01:00
|
|
|
|
2019-06-24 20:36:24 +02:00
|
|
|
**Capture** is a reverse proxy that takes an incoming HTTP request and sends it to another server,
|
|
|
|
proxying the response back to the client, while showing them in a dashboard
|
2017-11-08 00:10:54 +01:00
|
|
|
|
2018-11-17 11:55:14 +01:00
|
|
|
[![Build Status](https://travis-ci.com/ofabricio/capture.svg?branch=master)](https://travis-ci.com/ofabricio/capture)
|
2018-11-28 10:04:34 +01:00
|
|
|
[![Github Release](https://img.shields.io/github/release/ofabricio/capture.svg)](https://github.com/ofabricio/capture/releases)
|
2018-11-17 11:55:14 +01:00
|
|
|
|
2017-11-08 00:10:54 +01:00
|
|
|
|
2018-07-23 23:49:59 +02:00
|
|
|
## Running
|
2017-11-08 00:10:54 +01:00
|
|
|
|
2018-07-23 23:49:59 +02:00
|
|
|
./capture -url=https://example.com/
|
2017-11-08 00:10:54 +01:00
|
|
|
|
|
|
|
|
2019-11-09 00:27:02 +01:00
|
|
|
### Settings
|
2017-11-08 00:10:54 +01:00
|
|
|
|
2019-11-09 00:49:50 +01:00
|
|
|
| param | description |
|
|
|
|
|--------------|-------------|
|
|
|
|
| `-url` | **Required.** Set the url you want to proxy |
|
|
|
|
| `-port` | Set the proxy port. Default: *9000* |
|
|
|
|
| `-dashboard` | Set the dashboard port. Default: *9001* |
|
|
|
|
| `-captures` | Set how many captures to show in the dashboard. Default: *16* |
|
2017-11-08 00:10:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
## Using
|
|
|
|
|
|
|
|
If you set your base url as `http://example.com/api`, now `http://localhost:9000` points to that
|
|
|
|
address. Hence, calling `http://localhost:9000/users/1` is like calling `http://example.com/api/users/1`
|
|
|
|
|
2017-11-15 15:37:54 +01:00
|
|
|
*Capture* saves all requests and responses so that you can see them in the dashboard
|
2017-11-08 00:10:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
## Dashboard
|
|
|
|
|
2019-11-09 00:27:02 +01:00
|
|
|
To access the dashboard go to `http://localhost:9001/`
|
2018-07-23 23:49:59 +02:00
|
|
|
|
2017-11-08 00:10:54 +01:00
|
|
|
##### Preview
|
|
|
|
|
2018-11-25 22:24:59 +01:00
|
|
|
![dashboard](https://i.imgur.com/5pbLRRY.png)
|
2018-07-26 01:03:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
## Building
|
|
|
|
|
|
|
|
Manually:
|
|
|
|
|
2019-11-09 00:58:14 +01:00
|
|
|
git clone --depth 1 https://github.com/ofabricio/capture.git
|
2018-07-26 01:03:16 +02:00
|
|
|
cd capture
|
|
|
|
go build -o capture .
|
|
|
|
|
|
|
|
Via docker:
|
|
|
|
|
2019-11-09 00:58:14 +01:00
|
|
|
git clone --depth 1 https://github.com/ofabricio/capture.git
|
2018-07-26 01:03:16 +02:00
|
|
|
cd capture
|
2019-06-21 02:13:04 +02:00
|
|
|
docker run --rm -v "${PWD}:/src" -w /src -e GOOS=darwin golang:latest go build -o capture .
|
2018-11-17 11:55:04 +01:00
|
|
|
|
2019-03-10 18:32:35 +01:00
|
|
|
Now you have an executable binary in your directory
|
2018-11-17 11:55:04 +01:00
|
|
|
|
2018-11-24 11:02:53 +01:00
|
|
|
**Note:** you can change `GOOS=darwin` to `linux` or `windows`
|
2019-03-10 18:28:14 +01:00
|
|
|
|
|
|
|
## Plugins
|
|
|
|
|
|
|
|
Put [plugin](https://golang.org/pkg/plugin/) files in the current directory.
|
|
|
|
They are loaded sorted by filename on startup.
|
|
|
|
|
|
|
|
Plugins must export the following function:
|
|
|
|
|
|
|
|
```go
|
|
|
|
func Handler(proxy http.HandlerFunc) http.HandlerFunc {
|
|
|
|
return func(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
proxy.ServeHTTP(rw, r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|